This project has moved. For the latest updates, please go here.

Cell NumberFormat and Displayed Text

Aug 10, 2011 at 7:05 PM

Hi ,

 

I’m trying to format and .xlsx file and read the contents of the formatted file and export to a csv file. When exporting to the csv  the datecolumn value some of them are displayed as “40630”.

 

I have set the column style property as below:

worksheet.Column(2).Style.Numberformat.Format  = "mmmm dd yyyy"

 

When I look up the data in column the values look as the above format. While reading in code the cell.value=40630.

 

Ay ideas?

 

Cheers,

 

 

Vinitha

Coordinator
Aug 12, 2011 at 1:12 PM

Hi,

Dates are stored as numbers in Excel. Use the ExcelRange.GetValue<DateTime>() to convert it to a valid DateTime.

If you want the formatted value, use the ExcelRange.Text property.

Jan

Aug 12, 2011 at 6:17 PM

Thanks Jan. Will try that.

Sep 6, 2012 at 6:06 AM
Edited Sep 6, 2012 at 6:07 AM

Hi,

I want to export Integer values to a column in excel, but I see a small triange in the left top corner in all the cell saying "number is stored as text"

what should be done?