EasyXLS™ library allows you to calculate Excel formulas by defining formulas with functions or loading template Excel files with predefined formulas. The defined spreadsheet can be optionally exported to Excel.
The library can be used as Excel calculation engine. The engine provides all the functions supported by Excel as far as formulas are concerned. It provides arithmetic, logical and unary operators, formulas with numbers, dates and strings, formulas with cell references, formulas with cell ranges, formulas with names and with arrays.
Formula calculation is enabled by default. If the calculation was disabled, it must be enabled, otherwise the formulas are not calculated.
EasyXLS library can be integrated in:
- ASP.NET web pages - Windows applications - Windows Forms (WinForms) - Console applications - Windows service applications - ASP.NET MVC web applications - PHP and ASP web pages - Java applications
// Create an instance of the class that handles Excel files
ExcelDocument workbook = new ExcelDocument();
// Add a sheet
ExcelWorksheet xlsWorksheet = new ExcelWorksheet("Formula calculation");
workbook.easy_addWorksheet(xlsWorksheet);
// Get the table of data for the sheet
ExcelTable xlsTable = xlsWorksheet.easy_getExcelTable();
// Add data in cells and set the formula
xlsTable.easy_getCell("A1").setValue("1");
xlsTable.easy_getCell("A2").setValue("2");
xlsTable.easy_getCell("A3").setValue("3");
xlsTable.easy_getCell("A4").setValue("4");
xlsTable.easy_getCell("A6").setValue("=SUM(A1:A4)");
// Call the method that computes Excel formulas
String sError = xlsWorksheet.easy_computeFormulas(workbook, true);
if (sError.Length == 0)
Console.WriteLine("Formulas computed successfully");
else
Console.WriteLine("Error computing formulas! Error: " + sError);
// Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue());
// Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
' Create an instance of the class that handles Excel filesDim workbook As New ExcelDocument
' Add a sheetDim xlsWorksheet = New ExcelWorksheet("Formula calculation")
workbook.easy_addWorksheet(xlsWorksheet)
' Get the table of data for the sheetDim xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells and set the formula
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
xlsTable.easy_getCell("A6").setValue("=SUM(A1:A4)")
' Call the method that computes Excel formulasDim sError As String = xlsWorksheet.easy_computeFormulas(workbook, True)
If (sError.Equals("")) Then
Console.WriteLine(vbCrLf & "Formulas computed successfully")
Else
Console.WriteLine(vbCrLf & "Error computing formulas! Error: " & sError)
End If' Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " _
& xlsTable.easy_getCell(5, 0).getFormulaResultValue())
' Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx")
C++// Create an instance of the class that handles Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
// Add a sheet
EasyXLS::IExcelWorksheetPtr xlsWorksheet;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelWorksheet),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelWorksheet),
(void**) &xlsWorksheet) ;
xlsWorksheet->setSheetName("Formula calculation");
workbook->easy_addWorksheet(xlsWorksheet);
// Get the table of data for the sheet
EasyXLS::IExcelTablePtr xlsTable = xlsWorksheet->easy_getExcelTable();
// Add data in cells and set the formula
xlsTable->easy_getCell_2("A1")->setValue("1");
xlsTable->easy_getCell_2("A2")->setValue("2");
xlsTable->easy_getCell_2("A3")->setValue("3");
xlsTable->easy_getCell_2("A4")->setValue("4");
xlsTable->easy_getCell_2("A6")->setValue("=SUM(A1:A4)");
// Call the method that computes Excel formulas
_bstr_t sError =
xlsWorksheet->easy_computeFormulas(_variant_t((IDispatch*)workbook, true), true);
if (strcmp(sError, "") == 0)
printf("\nFormulas computed successfully");
else
printf("\nError computing formulas! Error: " + sError);
// Read formula result
printf("\nThe result of the formula entered at position A6 is: %s",
(LPCSTR)xlsTable->easy_getCell(5,0)->getFormulaResultValue());
// Export Excel file (optional)
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
C++.NET// Create an instance of the class that handles Excel files
ExcelDocument ^workbook = gcnew ExcelDocument();
// Add a sheet
ExcelWorksheet ^xlsWorksheet = gcnew ExcelWorksheet("Formula calculation");
workbook->easy_addWorksheet(xlsWorksheet);
// Get the table of data for the sheet
ExcelTable ^xlsTable = xlsWorksheet->easy_getExcelTable();
// Add data in cells and set the formula
xlsTable->easy_getCell("A1")->setValue("1");
xlsTable->easy_getCell("A2")->setValue("2");
xlsTable->easy_getCell("A3")->setValue("3");
xlsTable->easy_getCell("A4")->setValue("4");
xlsTable->easy_getCell("A6")->setValue("=SUM(A1:A4)");
// Call the method that computes Excel formulas
String ^sError = xlsWorksheet->easy_computeFormulas(workbook, true);
if (sError->Equals(""))
Console::WriteLine("Formulas computed successfully");
else
Console::WriteLine(String::Concat("Error computing formulas! Error: ", sError));
// Read formula result
Console::WriteLine(String::Concat(
"The result of the formula entered at position A6 is: ",
xlsTable->easy_getCell(5,0)->getFormulaResultValue()));
// Export Excel file (optional)
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
// Create an instance of the class that handles Excel files
ExcelDocument workbook = new ExcelDocument();
// Add a sheet
ExcelWorksheet xlsWorksheet = new ExcelWorksheet("Formula calculation");
workbook.easy_addWorksheet(xlsWorksheet);
// Get the table of data for the sheet
ExcelTable xlsTable = xlsWorksheet.easy_getExcelTable();
// Add data in cells and set the formula
xlsTable.easy_getCell("A1").setValue("1");
xlsTable.easy_getCell("A2").setValue("2");
xlsTable.easy_getCell("A3").setValue("3");
xlsTable.easy_getCell("A4").setValue("4");
xlsTable.easy_getCell("A6").setValue("=SUM(A1:A4)");
// Call the method that computes Excel formulas
String sError = xlsWorksheet.easy_computeFormulas(workbook, true);
if (sError.Length == 0)
Console.WriteLine("Formulas computed successfully");
else
Console.WriteLine("Error computing formulas! Error: " + sError);
// Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue());
// Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
.NET:// Create an instance of the class that handles Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Add a sheet
$xlsWorksheet = new COM("EasyXLS.ExcelWorksheet");
$xlsWorksheet->setSheetName("Formula calculation");
$workbook->easy_addWorksheet($xlsWorksheet);
// Get the table of data for the sheet
$xlsTable = $xlsWorksheet->easy_getExcelTable();
// Add data in cells and set the formula
$xlsTable->easy_getCell_2("A1")->setValue("1");
$xlsTable->easy_getCell_2("A2")->setValue("2");
$xlsTable->easy_getCell_2("A3")->setValue("3");
$xlsTable->easy_getCell_2("A4")->setValue("4");
$xlsTable->easy_getCell_2("A6")->setValue("=SUM(A1:A4)");
// Call the method that computes Excel formulas
$sError = $xlsWorksheet->easy_computeFormulas($workbook, true);
if ($sError == "")
echo"Formulas computed successfully <br />";
elseecho"Error computing formulas! Error: " . $sError;
// Read formula resultecho"The result of the formula entered at position A6 is: " .
$xlsTable->easy_getCell(5,0)->getFormulaResultValue();
// Export excel file (optional)
$workbook->easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx");
Java:// Create an instance of the class that handles Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Add a sheet
$xlsWorksheet = new java("EasyXLS.ExcelWorksheet");
$xlsWorksheet->setSheetName("Formula calculation");
$workbook->easy_addWorksheet($xlsWorksheet);
// Get the table of data for the sheet
$xlsTable = $xlsWorksheet->easy_getExcelTable();
// Add data in cells and set the formula
$xlsTable->easy_getCell("A1")->setValue("1");
$xlsTable->easy_getCell("A2")->setValue("2");
$xlsTable->easy_getCell("A3")->setValue("3");
$xlsTable->easy_getCell("A4")->setValue("4");
$xlsTable->easy_getCell("A6")->setValue("=SUM(A1:A4)");
// Call the method that computes Excel formulas
$sError = $xlsWorksheet->easy_computeFormulas($workbook, true);
if ($sError == "")
echo"Formulas computed successfully <br />";
elseecho"Error computing formulas! Error: " . $sError;
// Read formula resultecho"The result of the formula entered at position A6 is: " .
$xlsTable->easy_getCell(5,0)->getFormulaResultValue();
// Export excel file (optional)
$workbook->easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx");
' Create an instance of the class that handles Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Add a sheetset xlsWorksheet = Server.CreateObject("EasyXLS.ExcelWorksheet")
xlsWorksheet.setSheetName("Formula calculation")
workbook.easy_addWorksheet(xlsWorksheet)
' Get the table of data for the sheetset xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells and set the formula
xlsTable.easy_getCell_2("A1").setValue("1")
xlsTable.easy_getCell_2("A2").setValue("2")
xlsTable.easy_getCell_2("A3").setValue("3")
xlsTable.easy_getCell_2("A4").setValue("4")
xlsTable.easy_getCell_2("A6").setValue("=SUM(A1:A4)")
' Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, true)
if sError = ""then
response.write("Formulas computed successfully <br />")
else
response.write("Error computing formulas! Error: " + sError)
end if' Read formula result
response.write("The result of the formula entered at position A6 is: " + _
xlsTable.easy_getCell(5,0).getFormulaResultValue())
' Export Excel file (optional)
workbook.easy_WriteXLSXFile ("C:\Samples\Excel calculation.xlsx")
' Create an instance of the class that handles Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Add a sheetSet xlsWorksheet = CreateObject("EasyXLS.ExcelWorksheet")
xlsWorksheet.setSheetName ("Formula calculation")
workbook.easy_addWorksheet (xlsWorksheet)
' Get the table of data for the sheetSet xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells and set the formula
xlsTable.easy_getCell_2("A1").setValue ("1")
xlsTable.easy_getCell_2("A2").setValue ("2")
xlsTable.easy_getCell_2("A3").setValue ("3")
xlsTable.easy_getCell_2("A4").setValue ("4")
xlsTable.easy_getCell_2("A6").setValue ("=SUM(A1:A4)")
' Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
If sError = ""Then
Me.Label1.Caption = Me.Label1.Caption & vbCrLf & "Formulas computed successfully"Else
Me.Label1.Caption = Me.Label1.Caption & vbCrLf & _
"Error computing formulas! Error: " & sError
End If' Read formula result
Me.Label1.Caption = Me.Label1.Caption & vbCrLf & _
"The result of the formula entered at position A6 is: " & _
xlsTable.easy_getCell(5, 0).getFormulaResultValue()
' Export Excel file (optional)
workbook.easy_WriteXLSXFile ("C:\Samples\Excel calculation.xlsx")
' Create an instance of the class that handles Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Add a sheetSet xlsWorksheet = CreateObject("EasyXLS.ExcelWorksheet")
xlsWorksheet.setSheetName ("Formula calculation")
workbook.easy_addWorksheet (xlsWorksheet)
' Get the table of data for the sheetSet xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells and set the formula
xlsTable.easy_getCell_2("A1").setValue ("1")
xlsTable.easy_getCell_2("A2").setValue ("2")
xlsTable.easy_getCell_2("A3").setValue ("3")
xlsTable.easy_getCell_2("A4").setValue ("4")
xlsTable.easy_getCell_2("A6").setValue ("=SUM(A1:A4)")
' Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
If sError = ""Then
WScript.StdOut.Write(vbcrlf & "Formulas computed successfully")
Else
WScript.StdOut.Write(vbcrlf & "Error computing formulas! Error: " & sError)
End If' Read formula result
WScript.StdOut.Write(vbcrlf & "The result of the formula entered at position A6 is: " _
& xlsTable.easy_getCell(5, 0).getFormulaResultValue())
' Export Excel file (optional)
workbook.easy_WriteXLSXFile ("C:\Samples\Excel calculation.xlsx")
<!-- Create an instance of the class that handles Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Add a sheet --><cfobject type="java"class="EasyXLS.ExcelWorksheet"name="xlsWorksheet"action="CREATE"><cfset xlsWorksheet.setSheetName("Formula calculation")><cfset workbook.easy_addWorksheet(xlsWorksheet)><!-- Get the table of data for the sheet --><cfset xlsTable = xlsWorksheet.easy_getExcelTable()><!-- Add data in cells and set the formula --><cfset xlsTable.easy_getCell("A1").setValue("1")><cfset xlsTable.easy_getCell("A2").setValue("2")><cfset xlsTable.easy_getCell("A3").setValue("3")><cfset xlsTable.easy_getCell("A4").setValue("4")><cfset xlsTable.easy_getCell("A6").setValue("=SUM(A1:A4)")><!-- Call the method that computes Excel formulas --><cfset sError = xlsWorksheet.easy_computeFormulas(workbook, true)><CFIF (sError IS "")><cfoutput>
Formulas computed successfully <br />
</cfoutput>
<CFELSE>
<cfoutput>
Error computing formulas! Error: #sError#
</cfoutput>
</CFIF><!-- Read formula result --><cfoutput>
The result of the formula entered at position A6 is:
#xlsTable.easy_getCell(5,0).getFormulaResultValue()#
</cfoutput><!-- Export Excel file (optional) --><cfset ret = workbook.easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx")>
.NET:# Create an instance of the class that handles Excel files
workbook = ExcelDocument()
# Add a sheet
xlsWorksheet = ExcelWorksheet("Formula calculation")
workbook.easy_addWorksheet(xlsWorksheet)
# Get the table of data for the sheet
xlsTable = xlsWorksheet.easy_getExcelTable()
# Add data in cells and set the formula
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
xlsTable.easy_getCell("A6").setValue("=SUM(A1:A4)")
# Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
if len(sError) == 0:
print("Formulas computed successfully")
else:
print("Error computing formulas! Error: " + sError)
# Read formula result
print("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue())
# Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx")
Java:# Create an instance of the class that handles Excel files
workbook = gateway.jvm.ExcelDocument()
# Add a sheet
xlsWorksheet = gateway.jvm.ExcelWorksheet("Formula calculation")
workbook.easy_addWorksheet(xlsWorksheet)
# Get the table of data for the sheet
xlsTable = xlsWorksheet.easy_getExcelTable()
# Add data in cells and set the formula
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
xlsTable.easy_getCell("A6").setValue("=SUM(A1:A4)")
# Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
if len(sError) == 0:
print("Formulas computed successfully")
else:
print("Error computing formulas! Error: " + sError)
# Read formula result
print("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue())
# Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx")
Excel functions
The calculation engine provides all the functions supported by Excel. The full list of formulas elements can be found at the following link.
EasyXLS allows you to import an Excel file as a template with predefined formulas with functions, calculate spreadsheet formulas and read the formula result.
The below source code sample shows how to load an Excel file with formula "=SUM(A1:A4)" set on A6 cell, populate A1-A4 cells with data, calculate Excel formulas and read the formula result.
// Create an instance of the class that imports/exports Excel files
ExcelDocument workbook = new ExcelDocument();
// Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx");
// Get the worksheet with formula
ExcelWorksheet xlsWorksheet =
(ExcelWorksheet)workbook.easy_getSheet("Formula calculation");
// Get the table of data for the sheet
ExcelTable xlsTable = xlsWorksheet.easy_getExcelTable();
// Add data in cells
xlsTable.easy_getCell("A1").setValue("1");
xlsTable.easy_getCell("A2").setValue("2");
xlsTable.easy_getCell("A3").setValue("3");
xlsTable.easy_getCell("A4").setValue("4");
// Call the method that computes Excel formulas
String sError = xlsWorksheet.easy_computeFormulas(workbook, true);
if (sError.Length == 0)
Console.WriteLine("Formulas computed successfully");
else
Console.WriteLine("Error computing formulas! Error: " + sError);
// Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue());
// Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
' Create an instance of the class that imports/exports Excel filesDim workbook As New ExcelDocument
' Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx")
' Get the worksheet with formulaDim xlsWorksheet As ExcelWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetDim xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
' Call the method that computes Excel formulasDim sError As String = xlsWorksheet.easy_computeFormulas(workbook, True)
If (sError.Equals("")) Then
Console.WriteLine(vbCrLf & "Formulas computed successfully")
Else
Console.WriteLine(vbCrLf & "Error computing formulas! Error: " & sError)
End If' Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " _
& xlsTable.easy_getCell(5, 0).getFormulaResultValue())
' Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx")
C++// Create an instance of the class that imports/exports Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
// Load template Excel file
workbook->easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx");
// Get the worksheet with formula
EasyXLS::IExcelWorksheetPtr xlsWorksheet =
workbook->easy_getSheet("Formula calculation");
// Get the table of data for the sheet
EasyXLS::IExcelTablePtr xlsTable = xlsWorksheet->easy_getExcelTable();
// Add data in cells
xlsTable->easy_getCell_2("A1")->setValue("1");
xlsTable->easy_getCell_2("A2")->setValue("2");
xlsTable->easy_getCell_2("A3")->setValue("3");
xlsTable->easy_getCell_2("A4")->setValue("4");
// Call the method that computes Excel formulas
_bstr_t sError =
xlsWorksheet->easy_computeFormulas(_variant_t((IDispatch*)workbook, true), true);
if (strcmp(sError, "") == 0)
printf("\nFormulas computed successfully");
else
printf("\nError computing formulas! Error: " + sError);
// Read formula result
printf("\nThe result of the formula entered at position A6 is: %s",
(LPCSTR)xlsTable->easy_getCell(5,0)->getFormulaResultValue());
// Export Excel file (optional)
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
C++.NET// Create an instance of the class that imports/exports Excel files
ExcelDocument ^workbook = gcnew ExcelDocument();
// Load template Excel file
workbook->easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx");
// Get the worksheet with formula
ExcelWorksheet ^xlsWorksheet =
safe_cast<ExcelWorksheet^>(workbook->easy_getSheet("Formula calculation"));
// Get the table of data for the sheet
ExcelTable ^xlsTable = xlsWorksheet->easy_getExcelTable();
// Add data in cells
xlsTable->easy_getCell("A1")->setValue("1");
xlsTable->easy_getCell("A2")->setValue("2");
xlsTable->easy_getCell("A3")->setValue("3");
xlsTable->easy_getCell("A4")->setValue("4");
// Call the method that computes Excel formulas
String ^sError = xlsWorksheet->easy_computeFormulas(workbook, true);
if (sError->Equals(""))
Console::WriteLine("Formulas computed successfully");
else
Console::WriteLine(String::Concat("Error computing formulas! Error: ", sError));
// Read formula result
Console::WriteLine(String::Concat(
"The result of the formula entered at position A6 is: ",
xlsTable->easy_getCell(5,0)->getFormulaResultValue()));
// Export Excel file (optional)
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
// Create an instance of the class that imports/exports Excel files
ExcelDocument workbook = new ExcelDocument();
// Load template Excel file
FileInputStream file = new FileInputStream("C:\\Samples\\Formula.xlsx");
workbook.easy_LoadXLSXFile(file);
// Get the worksheet with formula
ExcelWorksheet xlsWorksheet =
(ExcelWorksheet)workbook.easy_getSheet("Formula calculation");
// Get the table of data for the sheet
ExcelTable xlsTable = xlsWorksheet.easy_getExcelTable();
// Add data in cells
xlsTable.easy_getCell("A1").setValue("1");
xlsTable.easy_getCell("A2").setValue("2");
xlsTable.easy_getCell("A3").setValue("3");
xlsTable.easy_getCell("A4").setValue("4");
// Call the method that computes Excel formulas
String sError = xlsWorksheet.easy_computeFormulas(workbook, true);
if (sError.Length == 0)
Console.WriteLine("Formulas computed successfully");
else
Console.WriteLine("Error computing formulas! Error: " + sError);
// Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue());
// Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx");
.NET:// Create an instance of the class that imports/exports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Load template Excel file
$workbook->easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx");
// Get the worksheet with formula
$xlsWorksheet = $workbook->easy_getSheet("Formula calculation");
// Get the table of data for the sheet
$xlsTable = $xlsWorksheet->easy_getExcelTable();
// Add data in cells
$xlsTable->easy_getCell_2("A1")->setValue("1");
$xlsTable->easy_getCell_2("A2")->setValue("2");
$xlsTable->easy_getCell_2("A3")->setValue("3");
$xlsTable->easy_getCell_2("A4")->setValue("4");
// Call the method that computes Excel formulas
$sError = $xlsWorksheet->easy_computeFormulas($workbook, true);
if ($sError == "")
echo"Formulas computed successfully <br />";
elseecho"Error computing formulas! Error: " . $sError;
// Read formula resultecho"The result of the formula entered at position A6 is: " .
$xlsTable->easy_getCell(5,0)->getFormulaResultValue();
// Export excel file (optional)
$workbook->easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx");
Java:// Create an instance of the class that imports/exports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Load template Excel file
$workbook->easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx");
// Get the worksheet with formula
$xlsWorksheet = $workbook->easy_getSheet("Formula calculation");
// Get the table of data for the sheet
$xlsTable = $xlsWorksheet->easy_getExcelTable();
// Add data in cells
$xlsTable->easy_getCell("A1")->setValue("1");
$xlsTable->easy_getCell("A2")->setValue("2");
$xlsTable->easy_getCell("A3")->setValue("3");
$xlsTable->easy_getCell("A4")->setValue("4");
// Call the method that computes Excel formulas
$sError = $xlsWorksheet->easy_computeFormulas($workbook, true);
if ($sError == "")
echo"Formulas computed successfully <br />";
elseecho"Error computing formulas! Error: " . $sError;
// Read formula resultecho"The result of the formula entered at position A6 is: " .
$xlsTable->easy_getCell(5,0)->getFormulaResultValue();
// Export excel file (optional)
$workbook->easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx");
' Create an instance of the class that imports/exports Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Load template Excel file
workbook.easy_LoadXLSXFile("C:\Samples\Formula.xlsx")
' Get the worksheet with formulaset xlsWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetset xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells
xlsTable.easy_getCell_2("A1").setValue("1")
xlsTable.easy_getCell_2("A2").setValue("2")
xlsTable.easy_getCell_2("A3").setValue("3")
xlsTable.easy_getCell_2("A4").setValue("4")
' Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, true)
if sError = ""then
response.write("Formulas computed successfully <br />")
else
response.write("Error computing formulas! Error: " + sError)
end if' Read formula result
response.write("The result of the formula entered at position A6 is: " + _
xlsTable.easy_getCell(5,0).getFormulaResultValue())
' Export Excel file (optional)
workbook.easy_WriteXLSXFile ("C:\Samples\Excel calculation.xlsx")
' Create an instance of the class that imports/exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Load template Excel file
workbook.easy_LoadXLSXFile ("C:\Samples\Formula.xlsx")
' Get the worksheet with formulaSet xlsWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetSet xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells
xlsTable.easy_getCell_2("A1").setValue ("1")
xlsTable.easy_getCell_2("A2").setValue ("2")
xlsTable.easy_getCell_2("A3").setValue ("3")
xlsTable.easy_getCell_2("A4").setValue ("4")
' Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
If sError = ""Then
Me.Label1.Caption = Me.Label1.Caption & vbCrLf & "Formulas computed successfully"Else
Me.Label1.Caption = Me.Label1.Caption & vbCrLf & _
"Error computing formulas! Error: " & sError
End If' Read formula result
Me.Label1.Caption = Me.Label1.Caption & vbCrLf & _
"The result of the formula entered at position A6 is: " & _
xlsTable.easy_getCell(5, 0).getFormulaResultValue()
' Export Excel file (optional)
workbook.easy_WriteXLSXFile ("C:\Samples\Excel calculation.xlsx")
' Create an instance of the class that imports/exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx")
' Get the worksheet with formulaSet xlsWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetSet xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells
xlsTable.easy_getCell_2("A1").setValue ("1")
xlsTable.easy_getCell_2("A2").setValue ("2")
xlsTable.easy_getCell_2("A3").setValue ("3")
xlsTable.easy_getCell_2("A4").setValue ("4")
' Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
If sError = ""Then
WScript.StdOut.Write(vbcrlf & "Formulas computed successfully")
Else
WScript.StdOut.Write(vbcrlf & "Error computing formulas! Error: " & sError)
End If' Read formula result
WScript.StdOut.Write(vbcrlf & "The result of the formula entered at position A6 is: " _
& xlsTable.easy_getCell(5, 0).getFormulaResultValue())
' Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx")
<!-- Create an instance of the class that imports/exports Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Load template Excel file --><cfset ret = workbook.easy_LoadXLSXFile("C:\Samples\Formula.xlsx")><!-- Get the worksheet with formula --><cfset xlsWorksheet = workbook.easy_getSheet("Formula calculation")><!-- Get the table of data for the sheet --><cfset xlsTable = xlsWorksheet.easy_getExcelTable()><!-- Add data in cells --><cfset xlsTable.easy_getCell("A1").setValue("1")><cfset xlsTable.easy_getCell("A2").setValue("2")><cfset xlsTable.easy_getCell("A3").setValue("3")><cfset xlsTable.easy_getCell("A4").setValue("4")><!-- Call the method that computes Excel formulas --><cfset sError = xlsWorksheet.easy_computeFormulas(workbook, true)><CFIF (sError IS "")><cfoutput>
Formulas computed successfully <br />
</cfoutput>
<CFELSE>
<cfoutput>
Error computing formulas! Error: #sError#
</cfoutput>
</CFIF><!-- Read formula result --><cfoutput>
The result of the formula entered at position A6 is:
#xlsTable.easy_getCell(5,0).getFormulaResultValue()#
</cfoutput><!-- Export Excel file (optional) --><cfset ret = workbook.easy_WriteXLSXFile("C:\Samples\Excel calculation.xlsx")>
.NET:# Create an instance of the class that imports/exports Excel files
workbook = ExcelDocument()
# Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx")
# Get the worksheet with formula
xlsWorksheet = workbook.easy_getSheet("Formula calculation")
# Get the table of data for the sheet
xlsTable = xlsWorksheet.easy_getExcelTable()
# Add data in cells
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
# Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
if len(sError) == 0:
print("Formulas computed successfully")
else:
print("Error computing formulas! Error: " + sError)
# Read formula result
print("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue())
# Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx")
Java:# Create an instance of the class that imports/exports Excel files
workbook = gateway.jvm.ExcelDocument()
# Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formula.xlsx")
# Get the worksheet with formula
xlsWorksheet = workbook.easy_getSheet("Formula calculation")
# Get the table of data for the sheet
xlsTable = xlsWorksheet.easy_getExcelTable()
# Add data in cells
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
# Call the method that computes Excel formulas
sError = xlsWorksheet.easy_computeFormulas(workbook, True)
if len(sError) == 0:
print("Formulas computed successfully")
else:
print("Error computing formulas! Error: " + sError)
# Read formula result
print("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue())
# Export Excel file (optional)
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel calculation.xlsx")
If only one formula result from one cell is required, for optimization purposes, only a specific cell can be calculated along with all other referenced cells that implies the formula value.
The below source code sample shows how to calculate one single cell from the worksheet.
// Create an instance of the class that imports Excel files
ExcelDocument workbook = new ExcelDocument();
// Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formulas.xlsx");
// Get the worksheet with formula
ExcelWorksheet xlsWorksheet = workbook.easy_getSheet("Formula calculation");
// Get the table of data for the sheet
ExcelTable xlsTable = xlsWorksheet.easy_getExcelTable();
// Add data in cells
xlsTable.easy_getCell("A1").setValue("1");
xlsTable.easy_getCell("A2").setValue("2");
xlsTable.easy_getCell("A3").setValue("3");
xlsTable.easy_getCell("A4").setValue("4");
// Call the method that computes cell formula
xlsTable.easy_getCell("A6").calculateFormula(workbook, xlsWorksheet,
xlsWorksheet, 5, 0, 5, 0, true);
// Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5, 0).getFormulaResultValue());
' Create an instance of the class that imports Excel filesDim workbook As New ExcelDocument()
' Load template Excel file
workbook.easy_LoadXLSXFile("C:\Samples\Formulas.xlsx")
' Get the worksheet with formulaDim xlsWorksheet As ExcelWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetDim xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
' Call the method that computes cell formula
xlsTable.easy_getCell("A6").calculateFormula(workbook, xlsWorksheet,
xlsWorksheet, 5, 0, 5, 0, True)
' Read Formula result
Console.WriteLine("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5, 0).getFormulaResultValue())
C++// Create an instance of the class that imports Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
// Load template Excel file
workbook->easy_LoadXLSXFile("C:\\Samples\\Formulas.xlsx");
// Get the worksheet with formula
EasyXLS::IExcelWorksheetPtr xlsWorksheet =
(EasyXLS::IExcelWorksheetPtr)workbook->easy_getSheet("Formula calculation");
// Get the table of data for the sheet
EasyXLS::IExcelTablePtr xlsTable = xlsWorksheet->easy_getExcelTable();
// Add data in cells
xlsTable->easy_getCell_2("A1")->setValue("1");
xlsTable->easy_getCell_2("A2")->setValue("2");
xlsTable->easy_getCell_2("A3")->setValue("3");
xlsTable->easy_getCell_2("A4")->setValue("4");
// Call the method that computes cell formula
xlsTable->easy_getCell_2("A6")->calculateFormula(_variant_t((IDispatch*)workbook, true),
_variant_t((IDispatch*)xlsWorksheet, true),
_variant_t((IDispatch*)xlsWorksheet, true), 5, 0, 5, 0, true);
// Read formula result
printf("The result of the formula entered at position A6 is: " +
xlsTable->easy_getCell(5, 0)->getFormulaResultValue());
C++.NET// Create an instance of the class that imports Excel files
ExcelDocument ^workbook = gcnew ExcelDocument();
// Load template Excel file
workbook->easy_LoadXLSXFile("C:\\Samples\\Formulas.xlsx");
// Get the worksheet with formula
ExcelWorksheet ^xlsWorksheet =
safe_cast<ExcelWorksheet^>(workbook->easy_getSheet("Formula calculation"));
// Get the table of data for the sheet
ExcelTable ^xlsTable = xlsWorksheet->easy_getExcelTable();
// Add data in cells
xlsTable->easy_getCell("A1")->setValue("1");
xlsTable->easy_getCell("A2")->setValue("2");
xlsTable->easy_getCell("A3")->setValue("3");
xlsTable->easy_getCell("A4")->setValue("4");
// Call the method that computes Excel formulas
xlsTable->easy_getCell("A6")->calculateFormula(workbook, xlsWorksheet,
xlsWorksheet, 5, 0, 5, 0, true);
// Read formula result
Console::WriteLine(String::Concat(
"The result of the formula entered at position A6 is: ",
xlsTable->easy_getCell(5,0)->getFormulaResultValue()));
// Create an instance of the class that imports Excel files
ExcelDocument workbook = new ExcelDocument();
// Load template Excel file
FileInputStream file = new FileInputStream("C:\\Samples\\Formulas.xlsx");
workbook.easy_LoadXLSXFile(file);
// Get the worksheet with formula
ExcelWorksheet xlsWorksheet = workbook.easy_getSheet("Formula calculation");
// Get the table of data for the sheet
ExcelTable xlsTable = xlsWorksheet.easy_getExcelTable();
// Add data in cells
xlsTable.easy_getCell("A1").setValue("1");
xlsTable.easy_getCell("A2").setValue("2");
xlsTable.easy_getCell("A3").setValue("3");
xlsTable.easy_getCell("A4").setValue("4");
// Call the method that computes cell formula
xlsTable.easy_getCell("A6").calculateFormula(workbook, xlsWorksheet,
xlsWorksheet, 5, 0, 5, 0, true);
// Read formula result
Console.WriteLine("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5, 0).getFormulaResultValue());
.NET:// Create an instance of the class that imports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Load template Excel file
$workbook->easy_LoadXLSXFile("C:\Samples\Formulas.xlsx");
// Get the worksheet with formula
$xlsWorksheet = $workbook->easy_getSheet("Formula calculation");
// Get the table of data for the sheet
$xlsTable = $xlsWorksheet->easy_getExcelTable();
// Add data in cells
$xlsTable->easy_getCell_2("A1")->setValue("1");
$xlsTable->easy_getCell_2("A2")->setValue("2");
$xlsTable->easy_getCell_2("A3")->setValue("3");
$xlsTable->easy_getCell_2("A4")->setValue("4");
// Call the method that computes cell formula
$xlsTable->easy_getCell_2("A6")->calculateFormula($workbook, $xlsWorksheet,
$xlsWorksheet, 5, 0, 5, 0, true);
// Read formula resultecho"The result of the formula entered at position A6 is: " .
$xlsTable->easy_getCell(5,0)->getFormulaResultValue();
Java:// Create an instance of the class that imports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Load template Excel file
$workbook->easy_LoadXLSXFile("C:\Samples\Formulas.xlsx");
// Get the worksheet with formula
$xlsWorksheet = $workbook->easy_getSheet("Formula calculation");
// Get the table of data for the sheet
$xlsTable = $xlsWorksheet->easy_getExcelTable();
// Add data in cells
$xlsTable->easy_getCell("A1")->setValue("1");
$xlsTable->easy_getCell("A2")->setValue("2");
$xlsTable->easy_getCell("A3")->setValue("3");
$xlsTable->easy_getCell("A4")->setValue("4");
// Call the method that computes cell formula
$xlsTable->easy_getCell("A6")->calculateFormula($workbook, $xlsWorksheet,
$xlsWorksheet, 5, 0, 5, 0, true);
// Read formula resultecho"The result of the formula entered at position A6 is: " .
$xlsTable->easy_getCell(5,0)->getFormulaResultValue();
' Create an instance of the class that imports Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Load template Excel file
workbook.easy_LoadXLSXFile("C:\Samples\Formulas.xlsx")
' Get the worksheet with formulaset xlsWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetset xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells
xlsTable.easy_getCell_2("A1").setValue("1")
xlsTable.easy_getCell_2("A2").setValue("2")
xlsTable.easy_getCell_2("A3").setValue("3")
xlsTable.easy_getCell_2("A4").setValue("4")
' Call the method that computes cell formula
xlsTable.easy_getCell_2("A6").calculateFormula workbook, xlsWorksheet, _
xlsWorksheet, 5, 0, 5, 0, true' Read formula result
response.write("The result of the formula entered at position A6 is: " + _
xlsTable.easy_getCell(5,0).getFormulaResultValue())
' Create an instance of the class that imports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Load template Excel file
workbook.easy_LoadXLSXFile ("C:\Samples\Formulas.xlsx")
' Get the worksheet with formulaSet xlsWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetSet xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells and set the formula
xlsTable.easy_getCell_2("A1").setValue ("1")
xlsTable.easy_getCell_2("A2").setValue ("2")
xlsTable.easy_getCell_2("A3").setValue ("3")
xlsTable.easy_getCell_2("A4").setValue ("4")
' Call the method that computes cell formula
xlsTable.easy_getCell_2("A6").calculateFormula workbook, xlsWorksheet, _
xlsWorksheet, 5, 0, 5, 0, True' Read formula result
Me.Label1.Caption = Me.Label1.Caption & vbCrLf & _
"The result of the formula entered at position A6 is: " & _
xlsTable.easy_getCell(5, 0).getFormulaResultValue()
' Create an instance of the class that imports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Load template Excel file
workbook.easy_LoadXLSXFile("C:\Samples\Formulas.xlsx")
' Get the worksheet with formulaSet xlsWorksheet = workbook.easy_getSheet("Formula calculation")
' Get the table of data for the sheetSet xlsTable = xlsWorksheet.easy_getExcelTable()
' Add data in cells
xlsTable.easy_getCell_2("A1").setValue("1")
xlsTable.easy_getCell_2("A2").setValue("2")
xlsTable.easy_getCell_2("A3").setValue("3")
xlsTable.easy_getCell_2("A4").setValue("4")
' Call the method that computes cell formula
xlsTable.easy_getCell_2("A6").calculateFormula workbook, xlsWorksheet, _
xlsWorksheet, 5, 0, 5, 0, true' Read formula result
WScript.StdOut.Write(vbcrlf & "The result of the formula entered at position A6 is: " _
& xlsTable.easy_getCell(5, 0).getFormulaResultValue())
<!-- Create an instance of the class that imports Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Load template Excel file --><cfset workbook.easy_LoadXLSXFile("C:\Samples\Formulas.xlsx")><!-- Get the worksheet with formula --><cfset xlsWorksheet = workbook.easy_getSheet("Formula calculation")><!-- Get the table of data for the sheet --><cfset xlsTable = xlsWorksheet.easy_getExcelTable()><!-- Add data in cells --><cfset xlsTable.easy_getCell("A1").setValue("1")><cfset xlsTable.easy_getCell("A2").setValue("2")><cfset xlsTable.easy_getCell("A3").setValue("3")><cfset xlsTable.easy_getCell("A4").setValue("4")><!-- Call the method that computes cell formula --><cfset xlsTable.easy_getCell("A6").calculateFormula(workbook, xlsWorksheet,
xlsWorksheet, 5, 0, 5, 0, true)><!-- Read formula result --><cfoutput>
The result of the formula entered at position A6 is:
#xlsTable.easy_getCell(5,0).getFormulaResultValue()#
</cfoutput>
.NET:# Create an instance of the class that imports Excel files
workbook = ExcelDocument()
# Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formulas.xlsx")
# Get the worksheet with formula
xlsWorksheet = workbook.easy_getSheet("Formula calculation")
# Get the table of data for the sheet
xlsTable = xlsWorksheet.easy_getExcelTable()
# Add data in cells
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
# Call the method that computes cell formula
xlsTable.easy_getCell("A6").calculateFormula(workbook, xlsWorksheet,
xlsWorksheet, 5, 0, 5, 0, True)
# Read formula result
print("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue())
Java:# Create an instance of the class that imports Excel files
workbook = gateway.jvm.ExcelDocument()
# Load template Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\Formulas.xlsx")
# Get the worksheet with formula
xlsWorksheet = workbook.easy_getSheet("Formula calculation")
# Get the table of data for the sheet
xlsTable = xlsWorksheet.easy_getExcelTable()
# Add data in cells
xlsTable.easy_getCell("A1").setValue("1")
xlsTable.easy_getCell("A2").setValue("2")
xlsTable.easy_getCell("A3").setValue("3")
xlsTable.easy_getCell("A4").setValue("4")
# Call the method that computes cell formula
xlsTable.easy_getCell("A6").calculateFormula(workbook, xlsWorksheet,
xlsWorksheet, 5, 0, 5, 0, True)
# Read formula result
print("The result of the formula entered at position A6 is: " +
xlsTable.easy_getCell(5,0).getFormulaResultValue())
Circular references
EasyXLS allows you to detect the circular references that might occur when formulas are calculated. A list with all issues of this type can be accessed using ExcelDocument.getCircularReferences method. The circular references are also displayed at the console, if the console messages are enabled.
The iterative calculation can be enabled and the maximum number of iterations or maximum change can be adjusted using ExcelOptions.setIterativeCalculation method. The iterative calculation is disabled by default.
The below source code sample shows how to enable the iterative calculation, set the maximum number of iteration and maximum change.
// Create an instance of the class that exports Excel files
ExcelDocument workbook = new ExcelDocument();
// Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation(true, 100, 0.001);
' Create an instance of the class that exports Excel filesDim workbook As New ExcelDocument
' Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation(True, 100, 0.001)
C++// Create an instance of the class that exports Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
// Enable iterative calculation
workbook->easy_getOptions()->setIterativeCalculation(true, 100, 0.001);
C++.NET// Create an instance of the class that exports Excel files
ExcelDocument ^workbook = gcnew ExcelDocument();
// Enable iterative calculation
workbook->easy_getOptions()->setIterativeCalculation(true, 100, 0.001);
// Create an instance of the class that exports Excel files
ExcelDocument workbook = new ExcelDocument();
// Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation(true, 100, 0.001);
.NET:// Create an instance of the class that exports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Enable iterative calculation
$workbook->easy_getOptions()->setIterativeCalculation(true, 100, 0.001);
Java:// Create an instance of the class that exports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Enable iterative calculation
$workbook->easy_getOptions()->setIterativeCalculation(true, 100, 0.001);
' Create an instance of the class that exports Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation true, 100, 0.001
' Create an instance of the class that exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation True, 100, 0.001
' Create an instance of the class that exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation true, 100, 0.001
<!-- Create an instance of the class that exports Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Enable iterative calculation --><cfset ret = workbook.easy_getOptions().setIterativeCalculation(true, 100, 0.001)>
.NET:# Create an instance of the class that exports Excel files
workbook = ExcelDocument()
# Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation(True, 100, 0.001)
Java:# Create an instance of the class that exports Excel files
workbook = gateway.jvm.ExcelDocument()
# Enable iterative calculation
workbook.easy_getOptions().setIterativeCalculation(True, 100, 0.001)
EasyXLS offers the option to disable formula calculation for optimization purposes. If for any reason, formula calculation was previously disabled, it must be enabled using ExcelOptions.setCalculateFormulas method.
The below source code sample shows how to enable the formula calculation.
// Create an instance of the class that exports Excel files
ExcelDocument workbook = new ExcelDocument();
// Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas(true);
' Create an instance of the class that exports Excel filesDim workbook As New ExcelDocument
' Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas(True)
C++// Create an instance of the class that exports Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
// Enable formula calculation
workbook->easy_getOptions()->setCalculateFormulas(true);
C++.NET// Create an instance of the class that exports Excel files
ExcelDocument ^workbook = gcnew ExcelDocument();
// Enable formula calculation
workbook->easy_getOptions()->setCalculateFormulas(true);
// Create an instance of the class that exports Excel files
ExcelDocument workbook = new ExcelDocument();
// Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas(true);
.NET:// Create an instance of the class that exports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Enable formula calculation
$workbook->easy_getOptions()->setCalculateFormulas(true);
Java:// Create an instance of the class that exports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Enable formula calculation
$workbook->easy_getOptions()->setCalculateFormulas(true);
' Create an instance of the class that exports Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas true
' Create an instance of the class that exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas True
' Create an instance of the class that exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas true
<!-- Create an instance of the class that exports Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Enable formula calculation --><cfset ret = workbook.easy_getOptions().setCalculateFormulas(true)>
.NET:# Create an instance of the class that exports Excel files
workbook = ExcelDocument()
# Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas(True)
Java:# Create an instance of the class that exports Excel files
workbook = gateway.jvm.ExcelDocument()
# Enable formula calculation
workbook.easy_getOptions().setCalculateFormulas(True)
Getting started with EasyXLS Excel library
To download the trial version of EasyXLS Excel Library, press the below button:
If you already own a license key, you may login and download EasyXLS from your account.