mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
ef5447add7
commit
2857c0af65
@ -1031,7 +1031,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
|
|||||||
} else if (rowBean instanceof Hyperlink) {
|
} else if (rowBean instanceof Hyperlink) {
|
||||||
// Hyperlink当成一个值
|
// Hyperlink当成一个值
|
||||||
return writeRow(CollUtil.newArrayList(rowBean), isWriteKeyAsHead);
|
return writeRow(CollUtil.newArrayList(rowBean), isWriteKeyAsHead);
|
||||||
} else if (BeanUtil.isBean(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 {
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user