以其他语言实现小计或总计标签

可能的使用场景

有时,您希望以中文、日文、阿拉伯文、印地文等非英语语言显示小计和总计标签。使用 Aspose.Cells,您可以通过 GlobalizationSettings 类和 WorkbookSettings.GlobalizationSettings 属性实现这一点。请参阅如何使用 GlobalizationSettings 类。

以其他语言实现小计或总计标签

以下示例代码加载了 示例 Excel 文件,并在 中文 语言中实现了小计和总计名称。请检查此代码生成的 输出 Excel 文件 以供参考。

示例代码

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//This function will return the sub total name
public String getTotalName(int functionType)
{
return "Chinese Total - 可能的用法";
}
//This function will return the grand total name
public String getGrandTotalName(int functionType)
{
return "Chinese Grand Total - 可能的用法";
}
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(ImplementSubtotalGrandTotallabels.class) + "articles/";
// Load your source workbook
Workbook wb = new Workbook(dataDir + "sample.xlsx");
// Set the glorbalization setting to change subtotal and grand total
// names
GlobalizationSettings gsi = new GlobalizationSettingsImp();
wb.getSettings().setGlobalizationSettings(gsi);
// Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);
// Apply subtotal on A1:B10
CellArea ca = CellArea.createCellArea("A1", "B10");
ws.getCells().subtotal(ca, 0, ConsolidationFunction.SUM, new int[] { 2, 3, 4 });
// Set the width of the first column
ws.getCells().setColumnWidth(0, 40);
// Save the output excel file
wb.save(dataDir + "ImplementTotallabels_out.xlsx");