|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.alibaba.excel; |
|
|
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.function.Supplier; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.context.WriteContext; |
|
|
|
|
import com.alibaba.excel.write.ExcelBuilder; |
|
|
|
@ -41,25 +42,31 @@ public class ExcelWriter {
|
|
|
|
|
/** |
|
|
|
|
* Write data to a sheet |
|
|
|
|
* |
|
|
|
|
* @param data |
|
|
|
|
* Data to be written |
|
|
|
|
* @param writeSheet |
|
|
|
|
* Write to this sheet |
|
|
|
|
* @param data Data to be written |
|
|
|
|
* @param writeSheet Write to this sheet |
|
|
|
|
* @return this current writer |
|
|
|
|
*/ |
|
|
|
|
public ExcelWriter write(Collection<?> data, WriteSheet writeSheet) { |
|
|
|
|
return write(data, writeSheet, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Write data to a sheet |
|
|
|
|
* |
|
|
|
|
* @param supplier Data to be written |
|
|
|
|
* @param writeSheet Write to this sheet |
|
|
|
|
* @return this current writer |
|
|
|
|
*/ |
|
|
|
|
public ExcelWriter write(Supplier<Collection<?>> supplier, WriteSheet writeSheet) { |
|
|
|
|
return write(supplier.get(), writeSheet, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Write value to a sheet |
|
|
|
|
* |
|
|
|
|
* @param data |
|
|
|
|
* Data to be written |
|
|
|
|
* @param writeSheet |
|
|
|
|
* Write to this sheet |
|
|
|
|
* @param writeTable |
|
|
|
|
* Write to this table |
|
|
|
|
* @param data Data to be written |
|
|
|
|
* @param writeSheet Write to this sheet |
|
|
|
|
* @param writeTable Write to this table |
|
|
|
|
* @return this |
|
|
|
|
*/ |
|
|
|
|
public ExcelWriter write(Collection<?> data, WriteSheet writeSheet, WriteTable writeTable) { |
|
|
|
@ -67,6 +74,19 @@ public class ExcelWriter {
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Write value to a sheet |
|
|
|
|
* |
|
|
|
|
* @param supplier Data to be written |
|
|
|
|
* @param writeSheet Write to this sheet |
|
|
|
|
* @param writeTable Write to this table |
|
|
|
|
* @return this |
|
|
|
|
*/ |
|
|
|
|
public ExcelWriter write(Supplier<Collection<?>> supplier, WriteSheet writeSheet, WriteTable writeTable) { |
|
|
|
|
excelBuilder.addContent(supplier.get(), writeSheet, writeTable); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Fill value to a sheet |
|
|
|
|
* |
|
|
|
@ -91,6 +111,30 @@ public class ExcelWriter {
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Fill value to a sheet |
|
|
|
|
* |
|
|
|
|
* @param supplier |
|
|
|
|
* @param writeSheet |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public ExcelWriter fill(Supplier<Object> supplier, WriteSheet writeSheet) { |
|
|
|
|
return fill(supplier.get(), null, writeSheet); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Fill value to a sheet |
|
|
|
|
* |
|
|
|
|
* @param supplier |
|
|
|
|
* @param fillConfig |
|
|
|
|
* @param writeSheet |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public ExcelWriter fill(Supplier<Object> supplier, FillConfig fillConfig, WriteSheet writeSheet) { |
|
|
|
|
excelBuilder.fill(supplier.get(), fillConfig, writeSheet); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Close IO |
|
|
|
|
*/ |
|
|
|
@ -102,7 +146,6 @@ public class ExcelWriter {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Prevents calls to {@link #finish} from freeing the cache |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
protected void finalize() { |
|
|
|
|