Solved

Display format problem in excel sheet.

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apps blocked by Java 9 103
Vector, list Questions R 6 69
How to Have Macro Files Automatically "Edit" 5 76
programming a polycom voip phone 3 84
This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

739 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