قم بتنفيذ تسميات Subtotal أو Grand Total بلغات أخرى
Contents
[
Hide
]
سيناريوهات الاستخدام الممكنة
في بعض الأحيان ، تريد إظهار الإجمالي الفرعي والتسميات الإجمالية الكلية بلغات غير الإنجليزية مثل الصينية واليابانية والعربية والهندية وما إلى ذلك. يسمح لك Aspose.Cells بالقيام بذلك باستخدامالعولمة الإعداداتفئة والمصنف. إعدادات العولمة خاصية. يرجى الاطلاع على هذه المقالة حول كيفية الاستفادة منالعولمة الإعداداتصف دراسي
قم بتنفيذ تسميات Subtotal أو Grand Total بلغات أخرى
يقوم نموذج التعليمات البرمجية التالي بتحميل ملفنموذج ملف اكسل وتنفذ أسماء المجموع الفرعي والمجموع الكلي في اللغة الصينية. رجاء تاكد منإخراج ملف Excel تم إنشاؤها بواسطة هذا الرمز للرجوع اليها. نقوم أولاً بإنشاء فئة منالعولمة الإعداداتثم استخدمه في الكود الخاص بنا.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 - 可能的用法"; | |
} | |
} |
استخدم الآن الفئة التي تم إنشاؤها أعلاه في الكود كما يلي:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |