I'm using Apache POI to create a large Excel spreadsheet that is extremely formula heavy for a client that may later modify the code of my program with new formulas. The big issue that I'm running in to is dealing with the fact that the POI workbooks are 0-indexed for their rows and columns, while the Excel formulas deal with the document as if it was 1-indexed. I'm using a helped class to make the conversions right now:
class RowHelper {
public static int getCell(int col) {
return col - 1;
}
public static String getCellAddress(int row, int col) {
return CellReference.convertNumToColString(col) + row;
}
}
And when I edit rows in the document I write it like this:
posRow.getCell(RowHelper.getCell(189)).setCellFormula(String.format("COUNT(%1$s:%2$s)", RowHelper.getCellAddress(2, 177), RowHelper.getCellAddress(ActiveSheet.getPhysicalNumberOfRows(), 177)));
//=COUNT(FU2:FU477)
But this isn't very clean code and won't be very easy for the client to use later down the road. Is there a better way of doing this?