I am working through drawing borders in POI without creating needless
CellStyles. Still having trouble with BORDER_NONE, I am thinking that I
need to make the adjacent borders BORDER_NONE as well, and went looking for
a method to retrieve the SpreadsheetVersion. Only found some code for a
ternary that produces it based on the workbook's class. I still would like
to have a simple helper method like getSpreadsheetVersion() either in
WorkbookUtil, or in Workbook (and therefore XSSFWorkbook and HSSFWorkbook).
If in WorkbookUtil, it would return the results of the ternary:

public static SpreadsheetVersion getSpreadsheetVersion (Workbook workbook) {
    return (workbook instanceof HSSFWorkbook) ? SpreadsheetVersion.EXCEL97
:
           SpreadsheetVersion.EXCEL2007;
}

In XSSFWorkbook (and HSSFWorkbook) it would simply return the appropriate
spreadsheet version.

public SpreadsheetVersion getSpreadsheetVersion() {
    return SpreadsheetVersion.EXCEL2007;  // EXCEL97 for HSSFWorkbook
}

I would prefer to say ssV = workbook.getSpreadsheetVersion() verses the
above ternary where I need the spreadsheet version. The user shouldn't need
to know how it is derived, and if Microsoft changes the limits in the
future, we will be able to easily set it and allow userland code to remain
unchanged. Otherwise users of POI must know how the spreadsheet version is
derived.

For the moment I am going to put the code into WorkbookUtil since the Util
classes seem to be a more acceptable location for new contributors to put
stuff.

I would rather it go in the Workbook class though.

Reply via email to