Export to excel leaves off leading 0s

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I suppose the data in the first column is something like
0868. The excel is identify (too smart) data type of the
column as numeric.

Elton Wang
elton_wang@xxxxxxxxxxx

>-----Original Message-----
>When I export a datagrid to excel the leading 0s of the
first column are
>truncated. I am using the following code for the export:
>
>private void ExportToExcel()
> {
> Response.Clear();
> Response.Buffer = true;
> Response.ContentType
= "application/vnd.ms-excel";
> Response.Charset = "";
> this.EnableViewState = false;
> StringWriter tw = new StringWriter
();
> HtmlTextWriter hw = new
HtmlTextWriter(tw);
> reportGrid.Width = 800;
> hw.RenderBeginTag
(System.Web.UI.HtmlTextWriterTag.Html);
> //this.ClearControls(reportGrid);
> reportGrid.RenderControl(hw);
> hw.RenderEndTag();
> Response.Write(tw.ToString());
> Response.End();
> }
>
>How do I need to alter the code to prevent the truncation?
>
>--
>Message posted via http://www.dotnetmonster.com
>.
>
.



Relevant Pages

  • Re: Floating Point , Wide zero etc
    ... truncation of significant digits as opposed to using floating point numbers. ... Excel sample, but the code will STILL give wrong results The solution is to ... the currency data type in Excel code is a scaled integer number ...
    (comp.databases.pick)
  • When exporting to excel leading 0s are omitted
    ... When I export a datagrid to excel the leading 0s of the first column are ... private void ExportToExcel() ... How do I need to alter the code to prevent the truncation? ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Export to excel leaves off leading 0s
    ... When I export a datagrid to excel the leading 0s of the first column are ... private void ExportToExcel() ... How do I need to alter the code to prevent the truncation? ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Bug in Excel 2007 using Names/Ranges?
    ... a range for each of the first 300 cells in the first column. ... the value of the cell is set to a string ("blahx" ... Why does saving the workbook kill the performance of Excel? ... private Office.CommandBar MainMenuBar; ...
    (microsoft.public.excel.programming)
  • Re: Merging data from excel to word
    ... that you're essentially looking to have it Transposed from an Excel list ... populating the table with 4 records in the columns of ... Excel I have a 5 column spreadsheet with about 150 rows. ... the COLUMNS in Word, ie. the first column would contain field 1, field 2, ...
    (microsoft.public.mac.office.word)