mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
Merge pull request #3050 from GengMS/v5-dev
Issue#3048: 添加 数字单元格精度据单元格实际数值自动适配新特性;
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package cn.hutool.poi.excel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* https://github.com/dromara/hutool/issues/3048 Excel导出javaBean中有BigDecimal类型精度流失
|
||||
*
|
||||
*/
|
||||
public class Issue3048Test {
|
||||
@Test
|
||||
@Ignore
|
||||
public void excelOutPutBeanListToExcel(){
|
||||
List<TestBean> excelExportList = new ArrayList<>();
|
||||
excelExportList.add(new TestBean("1", new BigDecimal("1.22")));
|
||||
excelExportList.add(new TestBean("2", new BigDecimal("2.342")));
|
||||
excelExportList.add(new TestBean("3", new BigDecimal("1.2346")));
|
||||
ExcelWriter excelWriter = ExcelUtil.getWriter(true);
|
||||
excelWriter.setNumberAutoPrecision(true);
|
||||
excelWriter.write(excelExportList, true);
|
||||
excelWriter.flush(new File("e:/test.xlsx"));
|
||||
excelWriter.close();
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class TestBean{
|
||||
private String testKey;
|
||||
private BigDecimal testValue;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user