[英]Aspose Excel downloading having Issue of Rounding off to 2 digits for decimal data
在 Aspose 中,该字段正在四舍五入,即使它在 Excel 本身中获得了正确的十进制数据。 此外,我的代码中没有额外的四舍五入到小数点后两位的公式。
要设置 3 个十进制数字,您可以尝试使用 Style.Custom 属性而不是 Style.Number。 事实上,使用 Aspose.Cells 您可以使用建议的属性指定任何或您想要的十进制数字。 有关如何为数字指定 3 个十进制数字的示例代码,请参见以下示例代码:
示例代码:
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");
希望这会有所帮助,您也可以在专用论坛中发布查询。
PS。 我在 Aspose 担任支持开发人员/传播者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.