This commit is contained in:
Looly
2024-08-27 09:41:00 +08:00
parent d53d7a966c
commit 55b433c4ca

View File

@@ -905,35 +905,6 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
return this; return this;
} }
/**
* 写出一行根据rowBean数据类型不同写出情况如下
*
* <pre>
* 1、如果为Iterable直接写出一行
* 2、如果为MapisWriteKeyAsHead为true写出两行Map的keys做为一行values做为第二行否则只写出一行values
* 3、如果为Bean转为Map写出isWriteKeyAsHead为true写出两行Map的keys做为一行values做为第二行否则只写出一行values
* </pre>
*
* @param rowBean 写出的Bean
* @param isWriteKeyAsHead 为true写出两行Map的keys做为一行values做为第二行否则只写出一行values
* @return this
* @see #writeRow(Iterable)
* @see #writeRow(Map, boolean)
* @since 4.1.5
*/
public ExcelWriter writeRow(final Object rowBean, final boolean isWriteKeyAsHead) {
checkClosed();
// 模板写出
if (null != this.sheetTemplateWriter) {
this.sheetTemplateWriter.fillRow(rowBean);
return this;
}
getSheetDataWriter().writeRow(rowBean, isWriteKeyAsHead);
return this;
}
/** /**
* 填充非列表模板变量(一次性变量) * 填充非列表模板变量(一次性变量)
* *
@@ -948,23 +919,28 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
} }
/** /**
* 将一个Map写入到ExcelisWriteKeyAsHead为true写出行,Map的keys做为一行values做为第二行否则只写出一行values<br> * 写出行,根据rowBean数据类型不同写出情况如下
* 如果rowMap为空包括null则写出空行
* *
* @param rowMap 写出的Map为空包括null则写出空行 * <pre>
* 1、如果为Iterable直接写出一行
* 2、如果为MapisWriteKeyAsHead为true写出两行Map的keys做为一行values做为第二行否则只写出一行values
* 3、如果为Bean转为Map写出isWriteKeyAsHead为true写出两行Map的keys做为一行values做为第二行否则只写出一行values
* </pre>
*
* @param rowBean 写出的Bean可以是Map、Bean或Iterable
* @param isWriteKeyAsHead 为true写出两行Map的keys做为一行values做为第二行否则只写出一行values * @param isWriteKeyAsHead 为true写出两行Map的keys做为一行values做为第二行否则只写出一行values
* @return this * @return this
*/ */
public ExcelWriter writeRow(final Map<?, ?> rowMap, final boolean isWriteKeyAsHead) { public ExcelWriter writeRow(final Object rowBean, final boolean isWriteKeyAsHead) {
checkClosed(); checkClosed();
// 模板写出 // 模板写出
if (null != this.sheetTemplateWriter) { if (null != this.sheetTemplateWriter) {
this.sheetTemplateWriter.fillRow(rowMap); this.sheetTemplateWriter.fillRow(rowBean);
return this; return this;
} }
getSheetDataWriter().writeRow(rowMap, isWriteKeyAsHead); getSheetDataWriter().writeRow(rowBean, isWriteKeyAsHead);
return this; return this;
} }