نفذ Cell.FormulaLocal مماثل لنطاق Excel VBA

سيناريوهات الاستخدام الممكنة

Microsoft قد تحتوي صيغ Excel على أسماء مختلفة في مناطق أو مناطق أو لغات مختلفة. على سبيل المثال،مجموعالوظيفة تسمىسوم في المانيا. Aspose.Cells لا يمكنه العمل مع أسماء الوظائف غير الإنجليزية. في Microsoft Excel VBA ، يوجدالنطاق. الصيغة المحليةالخاصية التي تُرجع اسم الوظيفة حسب لغتها أو منطقتها. يوفر Aspose.Cells أيضًاCell.FormulaLocalخاصية لهذا الغرض. ومع ذلك ، لن تعمل هذه الخاصية إلا عندما يتم تنفيذهاGlobalizationSettings.GetLocalFunctionName (سلسلة معايير اسم)طريقة.

نفذ Cell.FormulaLocal مماثل لنطاق Excel VBA

يشرح نموذج التعليمات البرمجية التالي كيفية التنفيذGlobalizationSettings.GetLocalFunctionName (سلسلة معايير اسم) طريقة. تقوم الطريقة بإرجاع الاسم المحلي للدالة القياسية. إذا كان اسم الوظيفة القياسي هومجموع ، يعودUserFormulaLocal_SUM يمكنك تغيير الكود حسب احتياجاتك وإرجاع أسماء الوظائف المحلية الصحيحة على سبيل المثالمجموع يكونسوم في الألمانية ونص يكونТЕКСТبالروسية. يرجى أيضًا الاطلاع على إخراج وحدة التحكم لعينة التعليمات البرمجية الواردة أدناه للحصول على مرجع.

عينة من الرموز

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Aspose.Cells.Examples.CSharp.WorkbookSettings
{
class Implement_Cell_FormulaLocal_SimilarTo_Range_FormulaLocal
{
//Implement GlobalizationSettings class
class GS : GlobalizationSettings
{
public override string GetLocalFunctionName(string standardName)
{
//Change the SUM function name as per your needs.
if (standardName == "SUM")
{
return "UserFormulaLocal_SUM";
}
//Change the AVERAGE function name as per your needs.
if (standardName == "AVERAGE")
{
return "UserFormulaLocal_AVERAGE";
}
return "";
}//GetLocalFunctionName
}//GS:GlobalizationSettings
public static void Run()
{
//Create workbook
Workbook wb = new Workbook();
//Assign GlobalizationSettings implementation class
wb.Settings.GlobalizationSettings = new GS();
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access some cell
Cell cell = ws.Cells["C4"];
//Assign SUM formula and print its FormulaLocal
cell.Formula = "SUM(A1:A2)";
Console.WriteLine("Formula Local: " + cell.FormulaLocal);
//Assign AVERAGE formula and print its FormulaLocal
cell.Formula = "=AVERAGE(B1:B2, B5)";
Console.WriteLine("Formula Local: " + cell.FormulaLocal);
}
}
}

إخراج وحدة التحكم

Formula Local: =UserFormulaLocal_SUM(A1:A2)

Formula Local: =UserFormulaLocal_AVERAGE(B1:B2,B5)