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

Google Docs Snippets

Importing XML Data in Google Sheets Use the XMLIMPORT function The syntax is XMLIMPORT("url", "xpath") e.g. for importing an XML sitemap =IMPORTXML("https://www.hascode.com/sitemap.xml", "//\*[local-name()='url']/*[local-name()='loc']") Select the preceding cell in Google Sheets =INDIRECT(ADDRESS(ROW()-1,COLUMN()) Create a Todo List Counter in Google Sheets Each empty cell is a todo, each filled cell is done. That allows us the following output, that counts all preceding cells of each type: ="Done: "&(COUNTA(B3:INDIRECT(ADDRESS(ROW()-1,COLUMN())))&" Todo: " &COUNTIF(B3:INDIRECT(ADDRESS(ROW()-1,COLUMN())),"")) This outputs a label like "Done: 35 Todo: 142" ...

March 1, 2010 · 1 min · 78 words · Micha Kops