/** * Adjusts the column width to fit the contents.<p> * * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing.<p> * * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ @Override public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255 * 256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int) (width)); } }
/** * Compute width of a column and return the result * * @param sheet the sheet to calculate * @param column 0-based index of the column * @param useMergedCells whether to use merged cells * @return the width in pixels or -1 if all cells are empty */ public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells) { return getColumnWidth(sheet, column, useMergedCells, sheet.getFirstRowNum(), sheet.getLastRowNum()); }
/** * Adjusts the column width to fit the contents. * <p> * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing. * </p> * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ @Override public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int)(width)); columnHelper.setColBestFit(column, true); } }
final int activeWidth = (int) (256 * SheetUtil.getColumnWidth(this, column, useMergedCells));
/** * Adjusts the column width to fit the contents. * <p> * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing. * </p> * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int)(width)); } }
/** * Adjusts the column width to fit the contents. * <p/> * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing. * <p/> * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255 * 256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int) (width)); } }
/** * Adjusts the column width to fit the contents. * * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing. * * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int)(width)); } }
/** * Adjusts the column width to fit the contents.<p> * * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing.<p> * * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ @Override public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255 * 256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int) (width)); } }
/** * Compute width of a column and return the result * * @param sheet the sheet to calculate * @param column 0-based index of the column * @param useMergedCells whether to use merged cells * @return the width in pixels or -1 if all cells are empty */ public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells) { return getColumnWidth(sheet, column, useMergedCells, sheet.getFirstRowNum(), sheet.getLastRowNum()); }
/** * Adjusts the column width to fit the contents. * <p> * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing. * </p> * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ @Override public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int)(width)); columnHelper.setColBestFit(column, true); } }
/** * Adjusts the column width to fit the contents. * <p> * This process can be relatively slow on large sheets, so this should * normally only be called once per column, at the end of your * processing. * </p> * You can specify whether the content of merged cells should be considered or ignored. * Default is to ignore merged cells. * * @param column the column index * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column */ public void autoSizeColumn(int column, boolean useMergedCells) { double width = SheetUtil.getColumnWidth(this, column, useMergedCells); if (width != -1) { width *= 256; int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters if (width > maxColumnWidth) { width = maxColumnWidth; } setColumnWidth(column, (int)(width)); columnHelper.setColBestFit(column, true); } }
final int activeWidth = (int) (256 * SheetUtil.getColumnWidth(this, column, useMergedCells));