static int getWidth(Sheet sheet, int col) { int width = sheet.getColumnWidth(col); if (width == sheet.getDefaultColumnWidth()) { width = (int) (width * 256); } return width; }
private int getTableWidth(Sheet sheet) { ensureColumnBounds(sheet); int width = 0; for (int i = firstColumn; i < endColumn; i++) { width = width + (sheet.getColumnWidth(i) / 32); } return width; }
private int getTableWidth(Sheet sheet) { ensureColumnBounds(sheet); int width = 0; for (int i = firstColumn; i < endColumn; i++) { width = width + (sheet.getColumnWidth(i) / 32); } return width; }
private int getTableWidth(Sheet sheet) { ensureColumnBounds(sheet); int width = 0; for (int i = firstColumn; i < endColumn; i++) { width = width + (sheet.getColumnWidth(i) / 32); } return width; }
private void printCols(Sheet sheet) { //out.format("<col/>%n"); ensureColumnBounds(sheet); for (int i = firstColumn; i < endColumn; i++) { out.format("<col style='width:%spx;' />%n", sheet.getColumnWidth(i) / 32); } }
static int getWidth(Sheet sheet, int col) { int width = sheet.getColumnWidth(col); if (width == sheet.getDefaultColumnWidth()) { width = (int) (width * 256); } return width; }
private void printCols(Sheet sheet) { //out.format("<col/>%n"); ensureColumnBounds(sheet); for (int i = firstColumn; i < endColumn; i++) { out.format("<col style='width:%spx;' />%n", sheet.getColumnWidth(i) / 32); } }
/** * Some magic numbers here What is column width??? */ public static int getColumnWidth(int col, Sheet sheet) { int w = sheet.getColumnWidth((short) col); if (w == sheet.getDefaultColumnWidth()) { return 79; } return w / 40; }
private void printCols(Sheet sheet) { //out.format("<col/>%n"); ensureColumnBounds(sheet); for (int i = firstColumn; i < endColumn; i++) { out.format("<col style='width:%spx;' />%n", sheet.getColumnWidth(i) / 32); } }
private void printCols(Sheet sheet) { // out.format("<col/>%n"); ensureColumnBounds(sheet); for (int i = firstColumn; i < endColumn; i++) { out.format("<col style='width:%spx;' />%n", sheet.getColumnWidth(i) / 32); } }
private int getTableWidth(Sheet sheet) { ensureColumnBounds(sheet); int width = 0; for (int i = firstColumn; i < endColumn; i++) { width = width + (sheet.getColumnWidth(i) / 32); } return width; }
private static final int WIDTH_ARROW_BUTTON = 1300; private void autosizeColumnsFromSheet(final Sheet excelSheet, final int fromColumn, final int toColumn) { for (int i = fromColumn; i <= toColumn; i++) { excelSheet.autoSizeColumn(new Short(String.valueOf(i))); try { excelSheet.setColumnWidth(i, excelSheet.getColumnWidth(i) + WIDTH_ARROW_BUTTON); } catch (final Exception e) { // don't do anything - just let autosize handle it } } }
private static void autoSizeColumns(Sheet sheet, int columnNumber) { for (int i = 0; i < columnNumber; i++) { int orgWidth = sheet.getColumnWidth(i); sheet.autoSizeColumn(i, true); int newWidth = (int) (sheet.getColumnWidth(i) + 100); if (newWidth > orgWidth) { sheet.setColumnWidth(i, newWidth); } else { sheet.setColumnWidth(i, orgWidth); } } }
private static void adjustColumnWidth(Sheet sheet, int lastColumn) { assert sheet != null; for (int i = 0; i <= lastColumn; i++) { sheet.autoSizeColumn(i); int width = sheet.getColumnWidth(i); if (width < MINIMUM_COLUMN_WIDTH) { sheet.setColumnWidth(i, MINIMUM_COLUMN_WIDTH); } } }
void autosize(Sheet sheet, int lastColumnIndex) { for (int i = 0; i <= lastColumnIndex; i++) { try { sheet.autoSizeColumn(i); } catch (Exception e) { // autosize depends on AWT stuff and can fail, but it should not be fatal LOG.warn("autoSizeColumn(" + i + ") failed: " + e.getMessage()); } int cw = sheet.getColumnWidth(i); // increase width to accommodate drop-down arrow in the header if (cw / 256 < 20) { sheet.setColumnWidth(i, 256 * 12); } else if (cw / 256 > 120) { sheet.setColumnWidth(i, 256 * 120); } } } }
@Override public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) { if (StringUtils.isNoneBlank(style.getWidth())) { int width = (int) Math.round(PoiCssUtils.getInt(style.getWidth()) * 2048 / 8.43F); Sheet sheet = cell.getSheet(); int colIndex = cell.getColumnIndex(); if (width > sheet.getColumnWidth(colIndex)) { if (width > 255 * 256) { width = 255 * 256; } sheet.setColumnWidth(colIndex, width); } } }
@Override public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) { if (StringUtils.isNoneBlank(style.getWidth())) { int width = (int) Math.round(PoiCssUtils.getInt(style.getWidth()) * 2048 / 8.43F); Sheet sheet = cell.getSheet(); int colIndex = cell.getColumnIndex(); if (width > sheet.getColumnWidth(colIndex)) { if (width > 255 * 256) { width = 255 * 256; } sheet.setColumnWidth(colIndex, width); } } }
public static void copySheets(Sheet newSheet, Sheet sheet) { int maxColumnNum = 0; for (int i = sheet.getFirstRowNum(), c = sheet.getLastRowNum(); i <= c; i++) { org.apache.poi.ss.usermodel.Row srcRow = sheet.getRow(i); org.apache.poi.ss.usermodel.Row destRow = newSheet.createRow(i); if (srcRow != null) { Util.copyRow(sheet, newSheet, srcRow, destRow); if (srcRow.getLastCellNum() > maxColumnNum) { maxColumnNum = srcRow.getLastCellNum(); } } } for (int i = 0; i <= maxColumnNum; i++) { newSheet.setColumnWidth(i, sheet.getColumnWidth(i)); } }
public static void copySheets(Sheet newSheet, Sheet sheet) { int maxColumnNum = 0; for (int i = sheet.getFirstRowNum(), c = sheet.getLastRowNum(); i <= c; i++) { org.apache.poi.ss.usermodel.Row srcRow = sheet.getRow(i); org.apache.poi.ss.usermodel.Row destRow = newSheet.createRow(i); if (srcRow != null) { Util.copyRow(sheet, newSheet, srcRow, destRow); if (srcRow.getLastCellNum() > maxColumnNum) { maxColumnNum = srcRow.getLastCellNum(); } } } for (int i = 0; i <= maxColumnNum; i++) { newSheet.setColumnWidth(i, sheet.getColumnWidth(i)); } }
public static void copySheets(Sheet newSheet, Sheet sheet, String expressionToReplace, String expressionReplacement) { int maxColumnNum = 0; for (int i = sheet.getFirstRowNum(), c = sheet.getLastRowNum(); i <= c; i++) { org.apache.poi.ss.usermodel.Row srcRow = sheet.getRow(i); org.apache.poi.ss.usermodel.Row destRow = newSheet.createRow(i); if (srcRow != null) { Util.copyRow(sheet, newSheet, srcRow, destRow, expressionToReplace, expressionReplacement); if (srcRow.getLastCellNum() > maxColumnNum) { maxColumnNum = srcRow.getLastCellNum(); } } } for (int i = 0; i <= maxColumnNum; i++) { newSheet.setColumnWidth(i, sheet.getColumnWidth(i)); } }