add methods

This commit is contained in:
Looly 2021-05-09 01:04:46 +08:00
parent 235d32043e
commit c984f3555f
3 changed files with 15 additions and 12 deletions

View File

@ -9,8 +9,9 @@
* 【http 】 HttpUtil增加closeCookie方法
* 【core 】 NumberUtil增加方法decimalFormat重载issue#I3OSA2@Gitee
* 【extra 】 Ftp的remoteVerificationEnabled改为falseissue#I3OSA2@Gitee
* 【core 】 MaskBit增加掩码反向转换的方法getMaskBit()pr#1563@Github
* 【core 】 ReUtil等增加indexOf、delLast等方法pr#1555@Github
* 【core 】 MaskBit增加掩码反向转换的方法getMaskBit()pr#1563@Github
* 【core 】 ReUtil等增加indexOf、delLast等方法pr#1555@Github
* 【poi 】 ExcelWriter增加writeSecHeadRow增加合并单元格边框颜色样式pr#318@Gitee
### 🐞Bug修复
* 【core 】 修复createScheduledExecutor单位不是毫秒的问题issue#I3OYIW@Gitee

View File

@ -722,14 +722,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
if (null != this.styleSet) {
style = (isSetHeaderStyle && null != this.styleSet.headCellStyle) ? this.styleSet.headCellStyle : this.styleSet.cellStyle;
}
CellUtil.mergingCells(this.sheet, firstRow, lastRow, firstColumn, lastColumn, style);
// 设置内容
if (null != content) {
final Cell cell = getOrCreateCell(firstColumn, firstRow);
CellUtil.setCellValue(cell, content, this.styleSet, isSetHeaderStyle);
}
return this;
return merge(firstRow, lastRow, firstColumn, lastColumn, content, style);
}
/**
@ -743,6 +737,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
* @param content 合并单元格后的内容
* @param cellStyle 合并后单元格使用的样式可以为null
* @return this
* @since 5.6.5
*/
public ExcelWriter merge(int firstRow, int lastRow, int firstColumn, int lastColumn, Object content, CellStyle cellStyle) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
@ -877,6 +872,10 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
* 写出的起始行为当前行号可使用{@link #getCurrentRow()}方法调用根据写出的的行数当前行号自动+1<br>
* 样式为默认标题样式可使用{@link #getHeadCellStyle()}方法调用后自定义默认样式
*
* <p>
* 此方法的逻辑是将一行数据写出到当前行遇到已存在的单元格跳过不存在的创建并赋值
* </p>
*
* @param rowData 一行的数据
* @return this
*/

View File

@ -4,18 +4,19 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.style.StyleUtil;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.junit.Ignore;
import org.junit.Test;
@ -553,13 +554,15 @@ public class ExcelWriteTest {
// 合并单元格后的标题行使用设置好的样式
writer.merge(0,1,0,row1.size() - 1, "标题XXXXXXXX",cellStyle);
System.out.println(writer.getCurrentRow());
Console.log(writer.getCurrentRow());
//设置复杂表头
writer.merge(2,3,0,0,"序号",true);
writer.merge(2,2,1,2,"AABB",true);
writer.merge(2,3,3,3,"CCCC",true);
writer.merge(2,2,4,5,"DDEE",true);
writer.setCurrentRow(3);
List<String> sechead = CollUtil.newArrayList("AA","BB","DD","EE");
writer.writeSecHeadRow(sechead);
// 一次性写出内容使用默认样式