Free Support Forum -

Question concerning number precision- Cell.PutValue(double)

Hi, I’m trying to use the Cell.PutValue(double d) method to put doubles into an Excel sheet, but I can’t figure out how to set the precision. I want to display numbers with a precision of 6 decimals, keeping trailing zeros (so .045 would be displayed as .045000, and .065789 is displayed as .065789). The relevant page in the Wiki is not coming up, so I thought I’d ask here. I can’t seem to figure it out using CellFormat.Custom.

Please try the following code:

Excel excel = new Excel();
Cell cell = excel.Worksheets[0].Cells[“A1”];
cell.Style.Custom = “0.000000”;
cell = excel.Worksheets[0].Cells[“A2”];
cell.Style.Custom = “0.000000”;