This commit is contained in:
Looly 2024-06-02 11:33:36 +08:00
parent 57b4dfa7a7
commit cb72dacc02
20 changed files with 93 additions and 24 deletions

View File

@ -1025,7 +1025,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
} else if (rowBean instanceof Hyperlink) { } else if (rowBean instanceof Hyperlink) {
// Hyperlink当成一个值 // Hyperlink当成一个值
return writeRow(ListUtil.of(rowBean), isWriteKeyAsHead); return writeRow(ListUtil.of(rowBean), isWriteKeyAsHead);
} else if (BeanUtil.isWritableBean(rowBean.getClass())) { } else if (BeanUtil.isReadableBean(rowBean.getClass())) {
if (MapUtil.isEmpty(this.headerAlias)) { if (MapUtil.isEmpty(this.headerAlias)) {
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<>(), false, false); rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<>(), false, false);
} else { } else {

View File

@ -10,8 +10,10 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.cell.CellEditor; import org.dromara.hutool.poi.excel.cell.CellEditor;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;

View File

@ -10,7 +10,7 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.core.io.resource.ResourceUtil; import org.dromara.hutool.core.io.resource.ResourceUtil;
import org.dromara.hutool.core.lang.Console; import org.dromara.hutool.core.lang.Console;
@ -19,6 +19,8 @@ import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.util.ObjUtil; import org.dromara.hutool.core.util.ObjUtil;
import lombok.Data; import lombok.Data;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,7 +10,7 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.core.collection.CollUtil; import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.ListUtil; import org.dromara.hutool.core.collection.ListUtil;
@ -19,6 +19,7 @@ import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.io.file.FileUtil; import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Console; import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.core.text.StrUtil; import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.cell.values.FormulaCellValue; import org.dromara.hutool.poi.excel.cell.values.FormulaCellValue;
import org.dromara.hutool.poi.excel.sax.Excel03SaxReader; import org.dromara.hutool.poi.excel.sax.Excel03SaxReader;
import org.dromara.hutool.poi.excel.sax.handler.RowHandler; import org.dromara.hutool.poi.excel.sax.handler.RowHandler;

View File

@ -10,9 +10,11 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import lombok.Data; import lombok.Data;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,9 +10,11 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.core.lang.Console; import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,8 +10,10 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,5 +1,8 @@
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.ExcelWriter;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,9 +10,10 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.core.lang.Console; import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,8 +10,10 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,8 +10,10 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,8 +1,10 @@
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import lombok.Data; import lombok.Data;
import org.dromara.hutool.core.annotation.Alias; import org.dromara.hutool.core.annotation.Alias;
import org.dromara.hutool.core.lang.Console; import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,5 +1,7 @@
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.reader;
import org.dromara.hutool.poi.excel.ExcelReader;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,13 +10,17 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.writer;
import org.dromara.hutool.core.collection.ListUtil; import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.date.DateUtil; import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.io.file.FileUtil; import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.map.MapUtil; import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.util.ObjUtil; import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.poi.excel.BigExcelWriter;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.ExcelWriter;
import org.dromara.hutool.poi.excel.TestBean;
import org.dromara.hutool.poi.excel.style.StyleUtil; import org.dromara.hutool.poi.excel.style.StyleUtil;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.FillPatternType;

View File

@ -0,0 +1,30 @@
package org.dromara.hutool.poi.excel.writer;
import lombok.Getter;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.ExcelWriter;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class ExcelWriteBeanTest {
@Test
@Disabled
public void writeRowTest() {
final MyBean bean = new MyBean("value1", "value2");
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/writeRowTest.xlsx");
writer.writeRow(bean, true);
writer.close();
}
@Getter
static class MyBean {
private final String property1;
private final String property2;
public MyBean(final String property1, final String property2) {
this.property1 = property1;
this.property2 = property2;
}
}
}

View File

@ -10,7 +10,7 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.writer;
import org.dromara.hutool.core.collection.ListUtil; import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.date.DateUtil; import org.dromara.hutool.core.date.DateUtil;
@ -20,6 +20,7 @@ import org.dromara.hutool.core.data.id.IdUtil;
import org.dromara.hutool.core.map.MapUtil; import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.util.CharsetUtil; import org.dromara.hutool.core.util.CharsetUtil;
import org.dromara.hutool.core.util.ObjUtil; import org.dromara.hutool.core.util.ObjUtil;
import org.dromara.hutool.poi.excel.*;
import org.dromara.hutool.poi.excel.cell.setters.EscapeStrCellSetter; import org.dromara.hutool.poi.excel.cell.setters.EscapeStrCellSetter;
import org.dromara.hutool.poi.excel.style.StyleUtil; import org.dromara.hutool.poi.excel.style.StyleUtil;
import org.apache.poi.common.usermodel.HyperlinkType; import org.apache.poi.common.usermodel.HyperlinkType;

View File

@ -10,10 +10,12 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.writer;
import org.dromara.hutool.core.collection.ListUtil; import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.map.MapUtil; import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.ExcelWriter;
import org.dromara.hutool.poi.excel.style.StyleUtil; import org.dromara.hutool.poi.excel.style.StyleUtil;
import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Font;

View File

@ -10,13 +10,17 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.writer;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.ExcelWriter;
import org.dromara.hutool.poi.excel.StyleSet;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -63,9 +67,9 @@ public class Issue2307Test {
} }
// 空串,实际应该有值 // 空串,实际应该有值
System.out.println("writer.getCell(1,0): " + writer.getCell(0,1)); Console.log("writer.getCell(1,0): " + writer.getCell(0,1));
System.out.println("writer.getCell(1,1): " + writer.getCell(1,1)); Console.log("writer.getCell(1,1): " + writer.getCell(1,1));
System.out.println("sheet.getRow(1).getCell(0): " + sheet.getRow(1).getCell(0)); Console.log("sheet.getRow(1).getCell(0): " + sheet.getRow(1).getCell(0));
} }
} }
} }

View File

@ -10,10 +10,12 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.writer;
import org.dromara.hutool.core.date.DateUtil; import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.io.file.FileUtil; import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.ExcelWriter;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -10,9 +10,12 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
package org.dromara.hutool.poi.excel; package org.dromara.hutool.poi.excel.writer;
import org.dromara.hutool.core.io.IORuntimeException; import org.dromara.hutool.core.io.IORuntimeException;
import org.dromara.hutool.poi.excel.ExcelUtil;
import org.dromara.hutool.poi.excel.ExcelWriter;
import org.dromara.hutool.poi.excel.WorkbookUtil;
import org.dromara.hutool.poi.excel.cell.CellUtil; import org.dromara.hutool.poi.excel.cell.CellUtil;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;