Solved

Display format problem in excel sheet.

Posted on 2004-09-22
3
444 Views
Last Modified: 2010-04-17
We are using C# language. The sql query data is dumped to excel sheet through data grid.
The number field is not properly displayed. The number 100003434 is displayed as 2.233456E.11.
But we need to display as 100003434.
below is the code used.


public class ExcelProblemInvoice : System.Web.UI.Page
      {
private string strVendorID = "";
protected System.Web.UI.WebControls.DataGrid datagridProblemInvoice;

private void Page_Load(object sender, System.EventArgs e)
{                  
try
{
if (Session["SESSION_USER_ID"] != null && Session["SESSION_USER_ID"].ToString() != "")
      {
      strVendorID = Session[ApplicationConstants.vendorID].ToString();
                  // Put user code to initialize the page here
                        Response.Clear();
                        Response.Charset = "";
                        Response.ContentType = "application/vnd.ms-excel";            
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);                
Controller controller = new Controller();
DataSet dataProblemInvoice = controller.SearchExcel(strVendorID );

      datagridProblemInvoice.DataSource = dataProblemInvoice;                                    
                        datagridProblemInvoice.DataBind();

                        datagridProblemInvoice.RenderControl(htmlWrite);

                        Response.Write(stringWrite.ToString());
                        Response.End();
                  }
0
Comment
Question by:ivega
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
PodExpert earned 125 total points
ID: 12130986
You have to use some string formating routine to convert your number to an appropriate format. String formating in C# is well explained here:

http://www.codeproject.com/csharp/custstrformat.asp

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question