Hi,
Thanks for your inquiry.
Well, I think your code is fine but the problem is with your data. Either you are filling it dynamically by Cell.PutValue() method or you have imported data from some source and the data was saved in string/text type in columns or objects. It is also possible that you have template file which has data stored as string/Text format. For your info, this is default behaviour of MS Excel, the reason is there is an option remains checked/on in MS Excel Options/Settings. So, if the numbers are stored as text, you will get green triangles onto those cells attached with the info (!) error that defines "numbers stored as text". To eliminate this info error, you need to uncheck that option manually in MS Excel. e.g.. in MS Excel 2003, click menu option.... Tools|Options|Error Checking tab, now uncheck the checkbox i.e.., "Number stored as text". I think you should convert the data to numbers to work fine with your formulas in the sheets. Following are some scenarios if any one is related to yours.
If you are inserting data into Cells dynamically, t it might be possible that you are inserting numbers as text like using Cell.PutValue("123") instead of Cell.PutValue(123). To rectify this, you may also try as: Cell.PutValue("123", true); to convert the text to numbers. Also, Nausherwan has provided an example with some description and explanation, you can also refer to it.
It is also possible that your so called numeric data stored in the datatable, is actually coming from string fields(columns).. Well, if so, and you are importing data from some table in some source, you may try the following overloaded method to convert data to numbers while filling the worksheet form data source:
public int ImportDataTable(
DataTable dataTable,
bool isFieldNameShown,
int firstRow,
byte firstColumn,
bool insertRows,
bool convertStringToNumber
);
Note: use true for the last parameter.
Kindly let us know if you need further clarifications, if you have some doubts, you can give us more information and post your template file here. We will be happy to sort it out.
Thank you.