إرجاع نطاق من القيم باستخدام AbstractCalculationEngine
Contents
[
Hide
]
يوفر Aspose.Cellsالخلاصةحساب المحرك فئة تُستخدم لتنفيذ وظائف معرّفة من قبل المستخدم أو وظائف مخصصة لا يدعمها Microsoft 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-Java | |
import java.util.ArrayList; | |
import com.aspose.cells.AbstractCalculationEngine; | |
import com.aspose.cells.CalculationData; | |
import com.aspose.cells.DateTime; | |
public class CustomFunctionStaticValue extends AbstractCalculationEngine { | |
@Override | |
public void calculate(CalculationData calculationData) { | |
calculationData.setCalculatedValue(new Object[][] { new Object[] { new DateTime(2015, 6, 12, 10, 6, 30), 2 }, | |
new Object[] { 3.0, "Test" } }); | |
} | |
} |
الآن استخدم الوظيفة المذكورة أعلاه في برنامجك.
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-Java | |
String outputDir = Utils.Get_OutputDirectory(); | |
Workbook workbook = new Workbook(); | |
Cells cells = workbook.getWorksheets().get(0).getCells(); | |
Cell cell = cells.get(0, 0); | |
cell.setArrayFormula("=MYFUNC()", 2, 2); | |
Style style = cell.getStyle(); | |
style.setNumber(14); | |
cell.setStyle(style); | |
CalculationOptions copt = new CalculationOptions(); | |
copt.setCustomEngine(new CustomFunctionStaticValue()); | |
workbook.calculateFormula(copt); | |
// Save to XLSX by setting the calc mode to manual | |
workbook.getSettings().getFormulaSettings().setCalculationMode(CalcModeType.MANUAL); | |
workbook.save(outputDir + "output.xlsx"); | |
// Save to PDF | |
workbook.save(outputDir + "output.pdf"); |