Calculate Formula while Assembling Spreadsheet Documents

Calculate Formula

The Recipe

  • Set up source document template path
  • Set up destination report path
  • Instantiate DocumentAssembler class
  • Set options, DocumentAssemblyOptions.UPDATE_FIELDS_AND_FORMULAS
  • Generate report

Download Template

Get the template from here.

The Code

// For complete examples and data files, please go to https://github.com/groupdocs-assembly/GroupDocs.Assembly-for-Java
String srcDocument = "/Spreadsheet Templates/Update formula.xlsx";
String docReport = "/Spreadsheet Reports/Update formula_report.xlsx";
try {
Manager manager = new DataStorage().getManagers().iterator().next();
DocumentAssembler assembler = new DocumentAssembler();
assembler.setOptions(DocumentAssemblyOptions.UPDATE_FIELDS_AND_FORMULAS);
assembler.assembleDocument(CommonUtilities.getTestDataPath(srcDocument),
CommonUtilities.getTestOutPath(docReport), new DataSourceInfo(new DataStorage(), null));
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
}
Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.