Home > database >  Aspose Excel downloading having Issue of Rounding off to 2 digits for decimal data
Aspose Excel downloading having Issue of Rounding off to 2 digits for decimal data

Time:09-27

In Aspose the field is getting rounded off even though it's getting proper decimal data in Excel itself. Also, there are no extra formulas of rounding off to 2 decimals in my code.

CodePudding user response:

To set 3 decimal digits, you may try using Style.Custom property instead of Style.Number. In fact, using Aspose.Cells you may specify any or your desired decimal digits using the suggested property. See the following sample code on how to specify 3 decimal digits for numbers:

Sample code:

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Cells["A1"].PutValue(3735.7564);
//Create a style object
Style style = workbook.CreateStyle();
//Set 3 decimal digits precision
style.Custom = "0.000";//also, using "0.0000" will set 4 decimal digits
//Apply the style to the cell
sheet.Cells["A1"].SetStyle(style);
//Save the Excel file
workbook.Save("e:\\test2\\out1.xlsx");

Hope this helps, you may also post queries in the dedicated https://reference.aspose.com/cells/net/aspose.cells/style/number/#:~:text=2-,Decimal,0.00,-3

  • Related