This commit is contained in:
Looly 2024-06-02 11:36:21 +08:00
parent ef5447add7
commit 2857c0af65
2 changed files with 30 additions and 1 deletions

View File

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

View File

@ -0,0 +1,29 @@
package cn.hutool.poi.excel;
import lombok.Getter;
import org.junit.Ignore;
import org.junit.Test;
public class ExcelWriteBeanTest {
@Test
@Ignore
public void writeRowTest() {
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(String property1, String property2) {
this.property1 = property1;
this.property2 = property2;
}
}
}