XlsUtils { public static int getColumnsNumberFromDimension(String dimension) { if (StringUtils.isEmpty(dimension)) { return 0; } String[] parts = StringUtils.split(dimension, ':'); if (parts.length < 2) { return 0; } String secondPart = parts[1]; return getColumnNumberFromCellRef(secondPart) + 1; } private  XlsUtils(); static String getCellValueAsString(Cell cell, FormulaEvaluator formulaEvaluator); static boolean isNewExcelFormat(InputStream inputStream); static List<String> getActiveSheetsFromWorkbookSpec(InputStream inputStream); static int getColumnsNumber(InputStream inputStream); static int getColumnsNumberFromDimension(String dimension); static int getColumnNumberFromCellRef(String lastCell);  }
@Test public void dimension_calculation() throws Exception { Assertions.assertThat(XlsUtils.getColumnsNumberFromDimension("A1:D5")).isEqualTo(4); Assertions.assertThat(XlsUtils.getColumnsNumberFromDimension("A1:A151")).isEqualTo(1); Assertions.assertThat(XlsUtils.getColumnsNumberFromDimension("B1:AG142")).isEqualTo(33); }