enableSheetCalculations method
void
enableSheetCalculations()
Enables the calculation support.
Workbook workbook = new Workbook(1);
Worksheet sheet = workbook.worksheets[0];
sheet.getRangeByIndex(1, 1).number = 10;
Range range1 = sheet.getRangeByIndex(1, 2);
range1.formula = '=A1';
sheet.enableSheetCalculations();
List<int> bytes = workbook.saveAsStream();
File('Formulas.xlsx').writeAsBytes(bytes);
workbook.dispose();
Implementation
void enableSheetCalculations() {
if (calcEngine == null) {
CalcEngine.parseArgumentSeparator =
book.getCultureInfo().textInfo.argumentSeparator;
CalcEngine.parseDecimalSeparator =
book.getCultureInfo().numberFormat.numberDecimalSeparator;
calcEngine = CalcEngine(this);
calcEngine!.useDatesInCalculations = true;
calcEngine!.useNoAmpersandQuotes = true;
final int sheetFamilyID = CalcEngine.createSheetFamilyID();
//register the sheet names with calculate
for (final Worksheet sheet in workbook.worksheets.innerList) {
if (sheet.calcEngine == null) {
sheet.calcEngine = CalcEngine(sheet);
sheet.calcEngine!.useDatesInCalculations = true;
sheet.calcEngine!.useNoAmpersandQuotes = true;
sheet.calcEngine!.excelLikeComputations = true;
}
if (CalcEngine.modelToSheetID != null &&
(CalcEngine.modelToSheetID!.containsKey(sheet))) {
CalcEngine.modelToSheetID!.remove(sheet);
}
sheet.calcEngine!.registerGridAsSheet(sheet.name, sheet, sheetFamilyID);
}
}
}