generalized autoResizeColumns(sheet) function

This commit is contained in:
2019-01-02 16:33:19 +01:00
parent d8e47d1eb0
commit 257def9140

View File

@ -54,7 +54,7 @@ public class WorkbookApp {
* @return the workbook loaded
* @throws FileNotFoundException if the workbook cannot be found
* @throws IOException if the workbook cannot be loaded
*/
*/
public Workbook loadWorkbook(String filename) throws IOException {
if (filename.toLowerCase().endsWith(".xlsx")) {
FileInputStream fis = new FileInputStream(new File(filename));
@ -290,4 +290,15 @@ public class WorkbookApp {
return null;
}
protected void autoResizeColumns(Sheet sheet) {
int maxColumn = sheet.getRow(0).getPhysicalNumberOfCells();
for (int currentColumn = 0; currentColumn < maxColumn; currentColumn++) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Auto resize column {}/{}", currentColumn, maxColumn);
}
sheet.autoSizeColumn(currentColumn);
}
}
}