Berechnen Sie Arbeitsmappenformeln
Contents
[
Hide
]
Berechnen Sie Arbeitsmappenformeln
Bitte verwendeIWorkbook->CalculateFormula()Methode, um die Formeln Ihrer Arbeitsmappe zu berechnen. Der folgende Beispielcode erläutert die Verwendung dieser Methode.
Beispielcode
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 | |
//Create a new workbook | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(); | |
//Get first worksheet which is created by default | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Adding a value to "A1" cell | |
intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1")); | |
cell->PutValue(5); | |
//Adding a value to "A2" cell | |
cell = ws->GetICells()->GetObjectByIndex(new String("A2")); | |
cell->PutValue(15); | |
//Adding a value to "A3" cell | |
cell = ws->GetICells()->GetObjectByIndex(new String("A3")); | |
cell->PutValue(25); | |
//Adding SUM formula to "A4" cell | |
cell = ws->GetICells()->GetObjectByIndex(new String("A4")); | |
cell->SetFormula(new String("=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->GetICells()->GetObjectByIndex(new String("A4")); | |
StringPtr sCalcuInfo = new String(L"Calculated Value of Cell A4: "); | |
Console::WriteLine(sCalcuInfo->StringAppend(cell->GetStringValue())); |
Konsolenausgabe
Dies ist die Konsolenausgabe des obigen Beispielcodes.
Calculated Value of Cell A4: 45