为工作簿指定自定义数字小数点和分组分隔符

使用Microsoft Excel指定自定义分隔符

下面的屏幕截图显示了“高级Excel选项”,并突出显示了指定“自定义分隔符”的部分。

todo:image_alt_text

使用Aspose.Cells指定自定义分隔符

下面的示例代码说明了如何使用Aspose.Cells API指定自定义分隔符。它将十进制和组分隔符分别指定为点和空格。

用于指定自定义数字小数点和分组分隔符的C#代码

// 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);
Workbook workbook = new Workbook();
// Specify custom separators
workbook.Settings.NumberDecimalSeparator = '.';
workbook.Settings.NumberGroupSeparator = ' ';
Worksheet worksheet = workbook.Worksheets[0];
// Set cell value
Cell cell = worksheet.Cells["A1"];
cell.PutValue(123456.789);
// Set custom cell style
Style style = cell.GetStyle();
style.Custom = "#,##0.000;[Red]#,##0.000";
cell.SetStyle(style);
worksheet.AutoFitColumns();
// Save workbook as pdf
workbook.Save(dataDir + "CustomSeparator_out.pdf");