احسب صيغ العمل في المصنف
Contents
[
Hide
]
احسب صيغ العمل في المصنف
يرجى استخدام Workbook.CalculateFormula() لحساب الصيغ في مصنفك. يشرح الكود المثالي التالي استخدام هذه الطريقة.
الكود المثالي
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-C | |
Aspose::Cells::Startup(); | |
//Create a new workbook | |
Workbook wb; | |
//Get first worksheet which is created by default | |
Worksheet ws = wb.GetWorksheets().Get(0); | |
//Adding a value to "A1" cell | |
Cell cell = ws.GetCells().Get(u"A1"); | |
cell.PutValue(5); | |
//Adding a value to "A2" cell | |
cell = ws.GetCells().Get(u"A2"); | |
cell.PutValue(15); | |
//Adding a value to "A3" cell | |
cell = ws.GetCells().Get(u"A3"); | |
cell.PutValue(25); | |
//Adding SUM formula to "A4" cell | |
cell = ws.GetCells().Get(u"A4"); | |
cell.SetFormula(u"=SUM(A1:A3)"); | |
//Calculating the results of formulas | |
wb.CalculateFormula(); | |
//Get the calculated value of the cell "A4" and print it on console | |
cell = ws.GetCells().Get(u"A4"); | |
std::cout << "Calculated Value of Cell A4: " << cell.GetStringValue().ToUtf8() << std::endl; | |
Aspose::Cells::Cleanup(); |
مخرجات الوحدة
هذا هو إنتاج الكونسول للكود العيني أعلاه.
Calculated Value of Cell A4: 45