Implementar Etiquetas de Subtotal o Gran Total en otros idiomas
Escenarios de uso posibles
A veces, deseas mostrar etiquetas de subtotal y gran total en idiomas no-ingleses como chino, japonés, árabe, hindi, etc. Aspose.Cells te permite hacer esto usando la clase GlobalizationSettings y la propiedad Workbook.GlobalizationSettings. Por favor consulta este artículo sobre cómo utilizar la clase GlobalizationSettings
Implementar Etiquetas de Subtotal o Gran Total en otros idiomas
El siguiente código de ejemplo carga el archivo de Excel de muestra e implementa los nombres de subtotal y gran total en el idioma chino. Por favor verifica el archivo de Excel de salida generado por este código para tu referencia. Primero creamos una clase GlobalizationSettings y luego la usamos en nuestro código.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
class GlobalizationSettingsImp : GlobalizationSettings | |
{ | |
// This function will return the sub total name | |
public override String GetTotalName(ConsolidationFunction functionType) | |
{ | |
return "Chinese Total - 可能的用法"; | |
} | |
// This function will return the grand total name | |
public override String GetGrandTotalName(ConsolidationFunction functionType) | |
{ | |
return "Chinese Grand Total - 可能的用法"; | |
} | |
} |
Ahora usa la clase creada anteriormente en el código como se muestra a continuación:
// 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); | |
// 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.Settings.GlobalizationSettings = gsi; | |
// Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
// Apply subtotal on A1:B10 | |
CellArea ca = CellArea.CreateCellArea("A1", "B10"); | |
ws.Cells.Subtotal(ca, 0, ConsolidationFunction.Sum, new int[] { 2, 3, 4 }); | |
// Set the width of the first column | |
ws.Cells.SetColumnWidth(0, 40); | |
// Save the output excel file | |
wb.Save(dataDir + "output_out.xlsx"); |