add setRowStyle

This commit is contained in:
Looly 2020-10-15 09:59:27 +08:00
parent 97d48dde0b
commit 3237df0855
2 changed files with 170 additions and 139 deletions

View File

@ -18,6 +18,7 @@
* 【core 】 完善注释pr#193@Gitee
* 【core 】 优化Combination.countAllpr#1159@Github
* 【core 】 优化针对list的split方法pr#194@Gitee
* 【poi 】 ExcelWriter增加setRowStyle方法
### Bug修复
* 【core 】 解决农历判断节日未判断大小月导致的问题issue#I1XHSF@Gitee

View File

@ -55,22 +55,37 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class ExcelWriter extends ExcelBase<ExcelWriter> {
/** 目标文件 */
/**
* 目标文件
*/
protected File destFile;
/** 当前行 */
/**
* 当前行
*/
private AtomicInteger currentRow = new AtomicInteger(0);
/** 标题行别名 */
/**
* 标题行别名
*/
private Map<String, String> headerAlias;
/** 是否只保留别名对应的字段 */
/**
* 是否只保留别名对应的字段
*/
private boolean onlyAlias;
/** 标题顺序比较器 */
/**
* 标题顺序比较器
*/
private Comparator<String> aliasComparator;
/** 样式集,定义不同类型数据样式 */
/**
* 样式集定义不同类型数据样式
*/
private StyleSet styleSet;
/** 标题项对应列号缓存,每次写标题更新此缓存 */
/**
* 标题项对应列号缓存每次写标题更新此缓存
*/
private Map<String, Integer> headLocationCache;
// -------------------------------------------------------------------------- Constructor start
/**
* 构造默认生成xls格式的Excel文件<br>
* 此构造不传入写出的Excel文件路径只能调用{@link #flush(OutputStream)}方法写出到流<br>
@ -995,6 +1010,20 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
return this;
}
/**
* 设置行样式
*
* @param y Y坐标从0计数即行号
* @param style 样式
* @return this
* @see Row#setRowStyle(CellStyle)
* @since 5.4.5
*/
public ExcelWriter setRowStyle(int y, CellStyle style) {
getOrCreateRow(y).setRowStyle(style);
return this;
}
/**
* 创建字体
*
@ -1090,6 +1119,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
}
// -------------------------------------------------------------------------- Private method start
/**
* 为指定的key列表添加标题别名如果没有定义key的别名在onlyAlias为false时使用原key
*