Cell Format?

Hi,

I am probably doing something silly, but need help please.

I am using PutValue to add a value to a particular cell and then I need to format the cell according to a style format. Eg if adding an integer I want to set the style to number format 1 and if a date then set to number format 15. This seems to work but Excel shows an error warning next to the number columns saying that it is a number stored as text? Also a date formatted field shows as the raw text I add - if I click the cell and hit enter - it changes the format to the style I requested!? It’s very strange.

Here is a bit of my code as an example:

-----
Worksheet sheet = Report.Worksheets[0];
Cells ReportCells = sheet.Cells;
Cell cell = ReportCells[StartRow, (byte)StartCol];
Styles styles = Report.Styles;
int styleIndex = styles.Add();
Aspose.Excel.Style style = Report.Styles[styleIndex];
//sql connection and query here…
style.Number = 15;
cell.Style = style;
cell.PutValue(myReader2.GetValue(0).ToString());
-----

Any clues?

Thanks,
Alex.

Dear Alex,

Thanks for your consideration.

The number format can only take effect on numeric values.

My suggestion is:

cell.PutValue(myReader2.GetValue(0));