mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fixed #1210
This commit is contained in:
parent
394d05f9d2
commit
235fdbfb86
@ -26,6 +26,7 @@ import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
||||
|
||||
import java.io.File;
|
||||
@ -268,6 +269,8 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
||||
* @since 4.0.12
|
||||
*/
|
||||
public ExcelWriter autoSizeColumn(int columnIndex) {
|
||||
SXSSFSheet sheet = (SXSSFSheet) this.sheet;
|
||||
sheet.trackAllColumnsForAutoSizing();
|
||||
this.sheet.autoSizeColumn(columnIndex);
|
||||
return this;
|
||||
}
|
||||
|
@ -16,11 +16,7 @@ import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 写出Excel单元测试
|
||||
@ -159,6 +155,29 @@ public class BigExcelWriteTest {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void issue1210() {
|
||||
// 通过工具类创建writer
|
||||
String path = "e:/issue1210.xlsx";
|
||||
FileUtil.del(path);
|
||||
BigExcelWriter writer = ExcelUtil.getBigWriter(path);
|
||||
writer.addHeaderAlias("id", "SN");
|
||||
writer.addHeaderAlias("userName", "User Name");
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
list.add(new HashMap<String, Object>(){{
|
||||
put("id", 1);
|
||||
put("userName", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
}});
|
||||
list.add(new HashMap<String, Object>(){{
|
||||
put("id", 2);
|
||||
put("userName", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
|
||||
}});
|
||||
writer.write(list, true);
|
||||
writer.autoSizeColumnAll();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void writeBeanTest() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user