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