java - 如何在 Apache poi 中设置多个单元格的样式

标签 java apache-poi

我正在研究如何使用单元格范围设置多个单元格的样式。查看我的代码以获取我当前的代码。预先感谢那些想要帮助我的人。

for (int counter = 0; counter < ColumnList.length; counter++) {
    SXSSFCell cell = currentRow.createCell(counter);
    if (counter == 0) {
       cell.setCellValue(String.valueOf(rowNum));
       cell.setCellStyle(cellStyle);
    } else {
      String columnValue = ColumnList[counter];                 
      String cellValue = rs.getString(columnValue);
      cell.setCellValue(cellValue);
      cell.setCellStyle(cellStyle);
    }

}

最佳答案

docs 上有一个 CellRangeAddress其中有一个您可以使用的构造函数:

CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol) 

关于java - 如何在 Apache poi 中设置多个单元格的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51057796/

相关文章:

java - 对 String[] 列表进行排序?

java - java中为什么要用XMLEncoder来序列化对象?

java - 可以确定要解压缩的文件的大小吗?

java - Apache POI 在编辑后保留预定义的宏

java - Apache POI - 如何将单元格值设置为日期格式?

java - 使用 Apache POI 使用 href 链接创建并下载 excel 文件

postgresql - 在红帽企业 Linux 中安装 JDK 1.6、JBoss 4.0 和 Postgresql

java - 使用 getIntent 从另一个类获取时字符串为 null

java - 如何使用 Apache POI 使用 getFilter() 方法过滤数据透视表

java - 如何在使用 Apache POI 和 java 创建的 .docx 上添加页码