Number formats

Oct 3, 2012 at 12:56 AM

My code exports varchar data from my database to an Excel sheet but a problem crops up with Excel showing all integar data as text. Basically, I see a small triange in the left top corner in all the cells saying "number is stored as text". What can I do to get my data in the right format. I am using VB.Net as my backend.  Thanks.

Oct 3, 2012 at 1:09 AM

If you are using any helper method, like LoadFromCollection, LoadFromDatatable, etc, make sure you add the datatable colums as numeric if they contains numeric data. If not, set the cell value directly without toString().

Oct 3, 2012 at 1:36 AM

I am not using any helper method, please find a snippet of my code below, thanks for ur immediate response


xlWorkSheet.Cells(row, col + 1).Value = dt.Rows(dtrow).ItemArray(col)


where dt is my data table, this runs in a loop.