generalized autoResizeColumns(sheet) function
This commit is contained in:
@ -54,7 +54,7 @@ public class WorkbookApp {
|
|||||||
* @return the workbook loaded
|
* @return the workbook loaded
|
||||||
* @throws FileNotFoundException if the workbook cannot be found
|
* @throws FileNotFoundException if the workbook cannot be found
|
||||||
* @throws IOException if the workbook cannot be loaded
|
* @throws IOException if the workbook cannot be loaded
|
||||||
*/
|
*/
|
||||||
public Workbook loadWorkbook(String filename) throws IOException {
|
public Workbook loadWorkbook(String filename) throws IOException {
|
||||||
if (filename.toLowerCase().endsWith(".xlsx")) {
|
if (filename.toLowerCase().endsWith(".xlsx")) {
|
||||||
FileInputStream fis = new FileInputStream(new File(filename));
|
FileInputStream fis = new FileInputStream(new File(filename));
|
||||||
@ -290,4 +290,15 @@ public class WorkbookApp {
|
|||||||
return null;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user