Specifying Significant Digits to be Stored in Excel File

Possible Usage Scenarios

By default, Aspose.Cells stores 17 significant digits of double values inside the excel file, unlike MS-Excel which stores only 15 significant digits. You can change the default behavior of Aspose.Cells from 17 significant digits to 15 significant digits using the CellsHelper.SignificantDigits property.

Specifying Significant Digits to be stored in Excel file

The following sample code enforces Aspose.Cells to use 15 significant digits while storing double values inside the excel file. Please check the output excel file. Change its extension to .zip and unzip it and you will see, only 15 significant digits are stored inside the excel file. The following screenshot explains the effect of CellsHelper.SignificantDigits property on the output excel file.

todo:image_alt_text

Sample Code

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//By default, Aspose.Cells stores 17 significant digits unlike
//MS-Excel which stores only 15 significant digits
CellsHelper.SignificantDigits = 15;
//Create workbook
Workbook workbook = new Workbook();
//Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Access cell A1
Cell c = worksheet.Cells["A1"];
//Put double value, only 15 significant digits as specified by
//CellsHelper.SignificantDigits above will be stored in excel file just like MS-Excel does
c.PutValue(1234567890.123451711);
//Save the workbook
workbook.Save(dataDir + "out_SignificantDigits.xlsx");