Snippet: Modifying Excel Files, Adding Formulas with Apache POI

Recently I needed to modify some excel files and to add some aggregated formula fields to a sheet and the following snippet did the work for me. Figure 1. Modified Excel File with Formulas Dependencies Just two dependencies needed here: One for Apache POI and one for the Office Open XML Documents API. <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.10.1</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.10.1</version> </dependency> Sample Excel File Our sample excel file is quite empty just some empty customer information and a chart that is bound to the data grid. ...

September 29, 2014 · 3 min · 493 words · Micha Kops