mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 09:35:29 +08:00
Pre Merge pull request !774 from miko/dev
This commit is contained in:
commit
c57a602821
@ -24,9 +24,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@ -36,6 +34,17 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ExcelUtil {
|
||||
private static final ThreadLocal<Set<String>> excludeFields = ThreadLocal.withInitial(HashSet::new);
|
||||
|
||||
public static void excludeFields(String... fields) {
|
||||
excludeFields.remove();
|
||||
Collections.addAll(excludeFields.get(), fields);
|
||||
}
|
||||
|
||||
|
||||
public static Set<String> getExcludeFields() {
|
||||
return excludeFields.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步导入(适用于小数据量)
|
||||
@ -195,6 +204,11 @@ public class ExcelUtil {
|
||||
.registerConverter(new ExcelBigNumberConvert())
|
||||
.registerWriteHandler(new DataWriteHandler(clazz))
|
||||
.sheet(sheetName);
|
||||
if(excludeFields.get()!=null && !excludeFields.get().isEmpty()){
|
||||
builder.excludeColumnFieldNames(excludeFields.get());
|
||||
excludeFields.remove();
|
||||
|
||||
}
|
||||
if (merge) {
|
||||
// 合并处理器
|
||||
builder.registerWriteHandler(new CellMergeStrategy(list, true));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user