mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
回退
This commit is contained in:
@@ -5,14 +5,14 @@ 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类型精度流失
|
||||
* https://github.com/dromara/hutool/issues/3048
|
||||
* Excel导出javaBean中有BigDecimal类型精度流失
|
||||
*
|
||||
*/
|
||||
public class Issue3048Test {
|
||||
@@ -22,11 +22,12 @@ public class Issue3048Test {
|
||||
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")));
|
||||
excelExportList.add(new TestBean("3", new BigDecimal("1.2346453453534534543545")));
|
||||
ExcelWriter excelWriter = ExcelUtil.getWriter(true);
|
||||
excelWriter.setNumberAutoPrecision(true);
|
||||
//excelWriter.setNumberAutoPrecision(true);
|
||||
excelWriter.write(excelExportList, true);
|
||||
excelWriter.flush(new File("e:/test.xlsx"));
|
||||
excelWriter.getStyleSet().getCellStyleForNumber().setDataFormat((short) 0);
|
||||
excelWriter.flush(new File("d:/test/test.xlsx"));
|
||||
excelWriter.close();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user