Export Excel tuncating leading zeros while export to excel from da



I have created windows application in VB.Net for export excel functionality
from datatable.
For this I used "Interop.Excel.dll" and "Interop.Office.dll" and created
worksheet as below

Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add

Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1),

For cntDs As Integer = 0 To dsExport.Tables.Count - 1

With excelWorksheet

End With


Its working fine. But once the data opened in the excel sheet (excel 2007),
if there is any number with leading zero (eg:00123), it will be truncated
which i dont want.

Even though if I change the format of excel sheet as text after loading the
data, the truncated zeros are not coming. Is there any property in excel 2007
to stop truncating leading zeros? Please advise.

Thanks in advance,



Dave Peterson

Try changing the number format to text before you put in the value. And make
sure that value that your using really contains the leading 0's.

Or leave the cell numeric, but give it a custom format of: 000000 (as many
leading 0's as you need).

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question