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);
}
}
}