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

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

以下屏幕截图显示了高级 Excel 选项并突出显示指定的部分自定义分隔符.

待办事项:图片_替代_文本

使用 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");