Numeric values set using PutValue are incompatible with OpenOffice

I am using

sheet.Cells[cellRange].PutValue(sValue);

to set numeric values into the cells.



In Microsoft Excel those cells are still seen as numeric and calculated fields involving those cells work correctly.



If I open the same worksheet with OpenOffice, though, the content is displayed as numeric but when you edit the cell you see that 5 really is stored as '5 (apostrophe in front).

This has the undesired effect that the value of the cell cannot be used by other cels for automatic calculations. ('5*4 is 0 and not 20)

Any chance that you can fix this?



Giorgio Malagutti

Hi,

Thanks for your details,

We will check your issue soon.

Thank you.

Hi,

Please try the following codes:

Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
cells["A1"].PutValue(5);
cells["A2"].PutValue("5");
cells["A3"].PutValue("5",true);
cells["B1"].Formula = "=A1*4";
cells["B2"].Formula = "=A2*4";
cells["B3"].Formula = "=A3*4";
// workbook.Save(@"C:\Book1.xls");

The value of B2 in OpenOffice is zero and the value of A2 is '5.So i think you must set a string value as the value. If you want to set a number value with string param, please use Cell."].PutValue(string stringValue, bool isConverted) method.

setting IsConverted to true solved the issue.

Many thanks for your prompt reply.



Giorgio