Solved

Display format problem in excel sheet.

Posted on 2004-09-22
3
436 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is about my first experience with programming Arduino.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now