Calculate Workbook Formulas
Contents
[
Hide
]
Calculate Workbook Formulas
Please use Workbook.CalculateFormula() method to calculate the formulas of your workbook. The following sample code explains the usage of this method.
Sample Code
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
workbook, _ := NewWorkbook() | |
worksheets, _ := workbook.GetWorksheets() | |
worksheet, _ := worksheets.Get_Int(0) | |
cells, _ := worksheet.GetCells() | |
cell, _ := cells.Get_String("A1") | |
cell.PutValue_Int(5) | |
cell, _ = cells.Get_String("A2") | |
cell.PutValue_Int(15) | |
cell, _ = cells.Get_String("A3") | |
cell.PutValue_Int(25) | |
cell, _ = cells.Get_String("A4") | |
cell.SetFormula_String("=SUM(A1:A3)") | |
workbook.CalculateFormula() | |
value, _ := cell.Get_IntValue() | |
println(value) |
Console Output
This is the console output of the above sample code.
Calculated Value of Cell A4: 45