mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -3,6 +3,7 @@ package cn.hutool.poi.word;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.poi.exceptions.POIException;
|
||||
@@ -158,7 +159,7 @@ public class Word07Writer implements Closeable {
|
||||
*/
|
||||
public Word07Writer addPicture(final File picFile, final int width, final int height) {
|
||||
final String fileName = picFile.getName();
|
||||
final String extName = FileUtil.extName(fileName).toUpperCase();
|
||||
final String extName = FileNameUtil.extName(fileName).toUpperCase();
|
||||
PicType picType;
|
||||
try {
|
||||
picType = PicType.valueOf(extName);
|
||||
|
@@ -52,7 +52,7 @@ public class BigExcelWriteTest {
|
||||
}
|
||||
|
||||
final String filePath = "e:/bigWriteTest.xlsx";
|
||||
FileUtil.del(filePath);
|
||||
FileUtil.del(FileUtil.file(filePath));
|
||||
// 通过工具类创建writer
|
||||
final BigExcelWriter writer = ExcelUtil.getBigWriter(filePath);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class BigExcelWriteTest {
|
||||
|
||||
// 通过工具类创建writer
|
||||
final String path = "e:/bigWriteMapTest.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
final BigExcelWriter writer = ExcelUtil.getBigWriter(path);
|
||||
|
||||
//设置内容字体
|
||||
@@ -148,7 +148,7 @@ public class BigExcelWriteTest {
|
||||
|
||||
// 通过工具类创建writer
|
||||
final String path = "e:/bigWriteMapTest2.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
final BigExcelWriter writer = ExcelUtil.getBigWriter(path);
|
||||
|
||||
// 一次性写出内容,使用默认样式
|
||||
@@ -177,7 +177,7 @@ public class BigExcelWriteTest {
|
||||
final List<cn.hutool.poi.excel.TestBean> rows = ListUtil.of(bean1, bean2);
|
||||
// 通过工具类创建writer
|
||||
final String file = "e:/bigWriteBeanTest.xlsx";
|
||||
FileUtil.del(file);
|
||||
FileUtil.del(FileUtil.file(file));
|
||||
final BigExcelWriter writer = ExcelUtil.getBigWriter(file);
|
||||
//自定义标题
|
||||
writer.addHeaderAlias("name", "姓名");
|
||||
@@ -197,7 +197,7 @@ public class BigExcelWriteTest {
|
||||
@Ignore
|
||||
public void writeCellValueTest() {
|
||||
final String path = "d:/test/cellValueTest.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
final BigExcelWriter writer = new BigExcelWriter(path);
|
||||
writer.writeCellValue(3, 5, "aaa");
|
||||
writer.close();
|
||||
@@ -210,7 +210,7 @@ public class BigExcelWriteTest {
|
||||
final Map<String, ?> map2 = MapUtil.of("id", "123457");
|
||||
final List<?> data = Arrays.asList(map1, map2);
|
||||
final String destFilePath = "d:/test/closeTest.xlsx";//略
|
||||
FileUtil.del(destFilePath);
|
||||
FileUtil.del(FileUtil.file(destFilePath));
|
||||
try (final ExcelWriter writer = ExcelUtil.getBigWriter(destFilePath)) {
|
||||
writer.write(data).flush();
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class BigExcelWriteTest {
|
||||
public void issue1210() {
|
||||
// 通过工具类创建writer
|
||||
final String path = "d:/test/issue1210.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
final BigExcelWriter writer = ExcelUtil.getBigWriter(path);
|
||||
writer.addHeaderAlias("id", "SN");
|
||||
writer.addHeaderAlias("userName", "User Name");
|
||||
|
@@ -147,7 +147,7 @@ public class ExcelWriteTest {
|
||||
}
|
||||
|
||||
final String filePath = "d:/test/writeTest.xlsx";
|
||||
FileUtil.del(filePath);
|
||||
FileUtil.del(FileUtil.file(filePath));
|
||||
// 通过工具类创建writer
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(filePath);
|
||||
// 通过构造方法创建writer
|
||||
@@ -294,7 +294,7 @@ public class ExcelWriteTest {
|
||||
|
||||
// 通过工具类创建writer
|
||||
final String path = "f:/test/writeMapWithStyleTest.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(path);
|
||||
writer.setStyleSet(null);
|
||||
|
||||
@@ -328,7 +328,7 @@ public class ExcelWriteTest {
|
||||
final List<Map<Object, Object>> rows = ListUtil.of(row1, row2);
|
||||
// 通过工具类创建writer
|
||||
final String file = "d:/test/writeMapAlias.xlsx";
|
||||
FileUtil.del(file);
|
||||
FileUtil.del(FileUtil.file(file));
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(file);
|
||||
// 自定义标题
|
||||
writer.addHeaderAlias("name", "姓名");
|
||||
@@ -363,7 +363,7 @@ public class ExcelWriteTest {
|
||||
final List<Map<Object, Object>> rows = ListUtil.of(row1, row2);
|
||||
// 通过工具类创建writer
|
||||
final String file = "f:/test/test_alias.xlsx";
|
||||
FileUtil.del(file);
|
||||
FileUtil.del(FileUtil.file(file));
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(file);
|
||||
writer.setOnlyAlias(true);
|
||||
// 自定义标题
|
||||
@@ -461,7 +461,7 @@ public class ExcelWriteTest {
|
||||
final List<cn.hutool.poi.excel.TestBean> rows = ListUtil.of(bean1, bean2);
|
||||
// 通过工具类创建writer
|
||||
final String file = "e:/writeBeanTest.xlsx";
|
||||
FileUtil.del(file);
|
||||
FileUtil.del(FileUtil.file(file));
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(file);
|
||||
// 自定义标题
|
||||
writer.addHeaderAlias("name", "姓名");
|
||||
@@ -493,7 +493,7 @@ public class ExcelWriteTest {
|
||||
final List<cn.hutool.poi.excel.OrderExcel> rows = ListUtil.of(order1, order2);
|
||||
// 通过工具类创建writer
|
||||
final String file = "f:/test/writeBeanTest2.xlsx";
|
||||
FileUtil.del(file);
|
||||
FileUtil.del(FileUtil.file(file));
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(file);
|
||||
// 自定义标题
|
||||
writer.addHeaderAlias("id", "编号");
|
||||
@@ -772,7 +772,7 @@ public class ExcelWriteTest {
|
||||
list.add(map2);
|
||||
|
||||
//通过工具类创建writer
|
||||
FileUtil.del("d:/test/writeTest2123.xlsx");
|
||||
FileUtil.del(FileUtil.file("d:/test/writeTest2123.xlsx"));
|
||||
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/writeTest2123.xlsx");
|
||||
writer.addHeaderAlias("xmnf", "项目年份");//1
|
||||
|
||||
@@ -790,7 +790,7 @@ public class ExcelWriteTest {
|
||||
|
||||
//通过工具类创建writer
|
||||
final String path = "d:/test/mergeForDate.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(path);
|
||||
writer.merge(0, 3, 0, 2, DateUtil.now(), false);
|
||||
writer.close();
|
||||
@@ -813,7 +813,7 @@ public class ExcelWriteTest {
|
||||
public void writeFloatTest() {
|
||||
//issue https://gitee.com/dromara/hutool/issues/I43U9G
|
||||
final String path = "d:/test/floatTest.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(path);
|
||||
writer.writeRow(ListUtil.view(22.9f));
|
||||
@@ -825,7 +825,7 @@ public class ExcelWriteTest {
|
||||
public void writeDoubleTest() {
|
||||
// https://gitee.com/dromara/hutool/issues/I5PI5C
|
||||
final String path = "d:/test/doubleTest.xlsx";
|
||||
FileUtil.del(path);
|
||||
FileUtil.del(FileUtil.file(path));
|
||||
|
||||
final ExcelWriter writer = ExcelUtil.getWriter(path);
|
||||
writer.disableDefaultStyle();
|
||||
|
@@ -16,7 +16,7 @@ public class Issue2307Test {
|
||||
@Ignore
|
||||
public void writeTest(){
|
||||
final String filePath = "d:/test/issue2307.xlsx";
|
||||
FileUtil.del(filePath);
|
||||
FileUtil.del(FileUtil.file(filePath));
|
||||
|
||||
final List<Object> row1 = ListUtil.of("设备1", 11, 111, 1111.444, 1111.444, 1111.444, 1111.444, 119999999999999999999999999999999999999999911.444);
|
||||
final List<Object> row2 = ListUtil.of("设备2", 22, 222, 2222.555, 2222.555, 2222.555, 2222.555, 2222.555);
|
||||
|
Reference in New Issue
Block a user