استخدام وظيفة FormulaText في Aspose.Cells

استخدام وظيفة FormulaText في Aspose.Cells

يعرض الرمز البريدي العيني التالي استخدام FormulaText مع Aspose.Cells. يكتب الرمز أولاً صيغة في الخلية A1 ثم يطبع نص الصيغة باستخدام FormulaText في الخلية A2.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getDataDir(UsingFormulaTextfunction.class);
// Create a workbook object
Workbook workbook = new Workbook();
// Access first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Put some formula in cell A1
Cell cellA1 = worksheet.getCells().get("A1");
cellA1.setFormula("=Sum(B1:B10)");
// Get the text of the formula in cell A2 using FORMULATEXT function
Cell cellA2 = worksheet.getCells().get("A2");
cellA2.setFormula("=FormulaText(A1)");
// Calculate the workbook
workbook.calculateFormula();
// Print the results of A2. It will now print the text of the formula inside cell A1
System.out.println(cellA2.getStringValue());

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

فيما يلي مخرجات وحدة الإدخال الخاصة بالكود المصدري أعلاه.

 =SUM(B1:B10)