org.apache.poi.ss.usermodel.Sheet.setDefaultColumnWidth()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.apache.poi.ss.usermodel.Sheet.setDefaultColumnWidth()方法的一些代码示例,展示了Sheet.setDefaultColumnWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sheet.setDefaultColumnWidth()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Sheet
类名称:Sheet
方法名:setDefaultColumnWidth

Sheet.setDefaultColumnWidth介绍

[英]Set the default column width for the sheet (if the columns do not define their own width) in characters
[中]以字符为单位设置工作表的默认列宽(如果列未定义自己的宽度)

代码示例

代码示例来源:origin: alibaba/easyexcel

public static Sheet buildSheetStyle(Sheet currentSheet, Map<Integer, Integer> sheetWidthMap){
  currentSheet.setDefaultColumnWidth(20);
  for (Map.Entry<Integer, Integer> entry : sheetWidthMap.entrySet()) {
    currentSheet.setColumnWidth(entry.getKey(), entry.getValue());
  }
  return currentSheet;
}

代码示例来源:origin: looly/hutool

/**
 * 设置列宽(单位为一个字符的宽度,例如传入width为10,表示10个字符的宽度)
 * 
 * @param columnIndex 列号(从0开始计数,-1表示所有列的默认宽度)
 * @param width 宽度(单位1~256个字符宽度)
 * @return this
 * @since 4.0.8
 */
public ExcelWriter setColumnWidth(int columnIndex, int width) {
  if (columnIndex < 0) {
    this.sheet.setDefaultColumnWidth(width);
  } else {
    this.sheet.setColumnWidth(columnIndex, width * 256);
  }
  return this;
}

代码示例来源:origin: looly/hutool

/**
 * 设置列宽(单位为一个字符的宽度,例如传入width为10,表示10个字符的宽度)
 * 
 * @param columnIndex 列号(从0开始计数,-1表示所有列的默认宽度)
 * @param width 宽度(单位1~256个字符宽度)
 * @return this
 * @since 4.0.8
 */
public ExcelWriter setColumnWidth(int columnIndex, int width) {
  if (columnIndex < 0) {
    this.sheet.setDefaultColumnWidth(width);
  } else {
    this.sheet.setColumnWidth(columnIndex, width * 256);
  }
  return this;
}

代码示例来源:origin: Vatavuk/excel-io

@Override
  public void accept(final Sheet sheet) {
    sheet.setDefaultColumnWidth(this.width);
  }
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 设置列宽(单位为一个字符的宽度,例如传入width为10,表示10个字符的宽度)
 * 
 * @param columnIndex 列号(从0开始计数,-1表示所有列的默认宽度)
 * @param width 宽度(单位1~256个字符宽度)
 * @return this
 * @since 4.0.8
 */
public ExcelWriter setColumnWidth(int columnIndex, int width) {
  if (columnIndex < 0) {
    this.sheet.setDefaultColumnWidth(width);
  } else {
    this.sheet.setColumnWidth(columnIndex, width * 256);
  }
  return this;
}

代码示例来源:origin: aboullaite/SpringBoot-Excel-Csv

sheet.setDefaultColumnWidth(30);

代码示例来源:origin: com.github.mg365/mg-common

s.setDefaultColumnWidth(15);

代码示例来源:origin: vakinge/jeesuite-libs

try {
  Sheet sheet = workbook.createSheet(this.sheetName);
  sheet.setDefaultColumnWidth(15); 
  CellStyle titleStyle = workbook.createCellStyle(); 
  titleStyle.setAlignment(HorizontalAlignment.CENTER);

相关文章

微信公众号

最新文章

更多