Browse Source

修复不自动行高的问题 [Issue #1869]

pull/2077/head
Jiaju Zhuang 3 years ago
parent
commit
56ab48e364
  1. 5
      src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java
  2. 37
      src/main/java/org/apache/poi/hssf/usermodel/PoiHssfUtils.java
  3. 12
      src/test/java/com/alibaba/easyexcel/test/temp/issue1662/Issue1662Test.java
  4. 1
      update.md

5
src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java

@ -28,6 +28,7 @@ import com.alibaba.excel.write.metadata.fill.FillWrapper;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.hssf.usermodel.PoiHssfUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
@ -322,6 +323,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
AnalysisCell analysisCell, boolean isOriginalCell) {
Row row = sheet.getRow(lastRowIndex);
if (row != null) {
checkRowHeight(analysisCell, fillConfig, isOriginalCell, row);
return row;
}
row = cachedSheet.getRow(lastRowIndex);
@ -351,7 +353,8 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
if (!analysisCell.getFirstRow() || !WriteDirectionEnum.VERTICAL.equals(fillConfig.getDirection())) {
return;
}
if (isOriginalCell) {
// fix https://github.com/alibaba/easyexcel/issues/1869
if (isOriginalCell && PoiHssfUtils.customHeight(row)) {
collectionRowHeightCache.put(currentUniqueDataFlag, row.getHeight());
return;
}

37
src/main/java/org/apache/poi/hssf/usermodel/PoiHssfUtils.java

@ -0,0 +1,37 @@
package org.apache.poi.hssf.usermodel;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.xssf.usermodel.XSSFRow;
/**
* utils
*
* @author Jiaju Zhuang
*/
public class PoiHssfUtils {
/**
* Whether to customize the height
*/
public static final BitField CUSTOM_HEIGHT = BitFieldFactory.getInstance(0x640);
/**
* Whether to customize the height
*
* @param row
* @return
*/
public static boolean customHeight(Row row) {
if (row instanceof XSSFRow) {
XSSFRow xssfRow = (XSSFRow)row;
return xssfRow.getCTRow().getCustomHeight();
}
if (row instanceof HSSFRow) {
HSSFRow hssfRow = (HSSFRow)row;
return CUSTOM_HEIGHT.getValue(hssfRow.getRowRecord().getOptionFlags()) == 1;
}
return false;
}
}

12
src/test/java/com/alibaba/easyexcel/test/temp/issue1662/Issue1662Test.java

@ -1,14 +1,16 @@
package com.alibaba.easyexcel.test.temp.issue1662;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import org.junit.Ignore;
import org.junit.Test;
@Ignore
public class Issue1662Test {
@Test
public void test1662() {

1
update.md

@ -20,6 +20,7 @@
* 修复无对象读 返回map的size可能会头的size不一致 [Issue #2014](https://github.com/alibaba/easyexcel/issues/2014)
* 修复合并头可能异常的bug [Issue #1662](https://github.com/alibaba/easyexcel/issues/1662)
* 修复填充调用横向样式策略报错 [Issue #1651](https://github.com/alibaba/easyexcel/issues/1651)
* 修复不自动行高的问题 [Issue #1869](https://github.com/alibaba/easyexcel/issues/1869)
# 2.2.10

Loading…
Cancel
Save