|
|
@ -26,8 +26,6 @@ import com.alibaba.excel.util.ClassUtils; |
|
|
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
import com.alibaba.excel.write.metadata.holder.AbstractWriteHolder; |
|
|
|
import com.alibaba.excel.write.metadata.holder.AbstractWriteHolder; |
|
|
|
|
|
|
|
|
|
|
|
import javafx.util.Pair; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Define the header attribute of excel |
|
|
|
* Define the header attribute of excel |
|
|
|
* |
|
|
|
* |
|
|
@ -129,7 +127,8 @@ public class ExcelHeadProperty { |
|
|
|
int index = 0; |
|
|
|
int index = 0; |
|
|
|
while (customFieldMap.containsKey(index)) { |
|
|
|
while (customFieldMap.containsKey(index)) { |
|
|
|
Field field = customFieldMap.get(index); |
|
|
|
Field field = customFieldMap.get(index); |
|
|
|
Map.Entry<Field, Boolean> fieldBooleanPair = new AbstractMap.SimpleEntry<Field, Boolean>(field, Boolean.TRUE); |
|
|
|
Map.Entry<Field, Boolean> fieldBooleanPair = |
|
|
|
|
|
|
|
new AbstractMap.SimpleEntry<Field, Boolean>(field, Boolean.TRUE); |
|
|
|
exportFieldBoolPairsList.add(fieldBooleanPair); |
|
|
|
exportFieldBoolPairsList.add(fieldBooleanPair); |
|
|
|
index++; |
|
|
|
index++; |
|
|
|
} |
|
|
|
} |
|
|
@ -148,19 +147,22 @@ public class ExcelHeadProperty { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Give the field and flag pair list and arrange them in the specified order according to the user's settings. |
|
|
|
* Give the field and flag pair list and arrange them in the specified order according to the user's settings. The |
|
|
|
* The field is what the user want to export to excel, the flag indicates whether the order of the field in excel is |
|
|
|
* field is what the user want to export to excel, the flag indicates whether the order of the field in excel is |
|
|
|
* specified. |
|
|
|
* specified. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param holder Write holder which keeps the parameters of a sheet. |
|
|
|
* @param holder |
|
|
|
* @param exportFieldBoolPairList Keep all the fields and the flag(which indicate whether the field order is specified) |
|
|
|
* Write holder which keeps the parameters of a sheet. |
|
|
|
* of the head class except the ignored. It will be modified after this function is called. |
|
|
|
* @param exportFieldBoolPairList |
|
|
|
|
|
|
|
* Keep all the fields and the flag(which indicate whether the field order is specified) of the head |
|
|
|
|
|
|
|
* class except the ignored. It will be modified after this function is called. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void sortExportColumnFields(Holder holder, List<Map.Entry<Field, Boolean>> exportFieldBoolPairList) { |
|
|
|
private void sortExportColumnFields(Holder holder, List<Map.Entry<Field, Boolean>> exportFieldBoolPairList) { |
|
|
|
if (holder instanceof AbstractWriteHolder) { |
|
|
|
if (holder instanceof AbstractWriteHolder) { |
|
|
|
Collection<String> includeColumnFieldNames = ((AbstractWriteHolder)holder).getIncludeColumnFieldNames(); |
|
|
|
Collection<String> includeColumnFieldNames = ((AbstractWriteHolder)holder).getIncludeColumnFieldNames(); |
|
|
|
if (includeColumnFieldNames != null) { |
|
|
|
if (includeColumnFieldNames != null) { |
|
|
|
Map<String, Map.Entry<Field, Boolean>> exportFieldMap = new TreeMap<String, Map.Entry<Field, Boolean>>(); |
|
|
|
Map<String, Map.Entry<Field, Boolean>> exportFieldMap = |
|
|
|
|
|
|
|
new TreeMap<String, Map.Entry<Field, Boolean>>(); |
|
|
|
List<String> includeColumnFieldNameList = new ArrayList<String>(includeColumnFieldNames); |
|
|
|
List<String> includeColumnFieldNameList = new ArrayList<String>(includeColumnFieldNames); |
|
|
|
for (Map.Entry<Field, Boolean> fieldBoolPair : exportFieldBoolPairList) { |
|
|
|
for (Map.Entry<Field, Boolean> fieldBoolPair : exportFieldBoolPairList) { |
|
|
|
if (includeColumnFieldNameList.contains(fieldBoolPair.getKey().getName())) { |
|
|
|
if (includeColumnFieldNameList.contains(fieldBoolPair.getKey().getName())) { |
|
|
@ -198,9 +200,11 @@ public class ExcelHeadProperty { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Initialize column properties. |
|
|
|
* Initialize column properties. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param holder Write holder which keeps the parameters of a sheet. |
|
|
|
* @param holder |
|
|
|
* @param exportFieldBoolPairList Keep the fields which will be exported to excel and the flag which indicate whether |
|
|
|
* Write holder which keeps the parameters of a sheet. |
|
|
|
* the field order in excel is specified. |
|
|
|
* @param exportFieldBoolPairList |
|
|
|
|
|
|
|
* Keep the fields which will be exported to excel and the flag which indicate whether the field order in |
|
|
|
|
|
|
|
* excel is specified. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void initColumnProperties(Holder holder, List<Map.Entry<Field, Boolean>> exportFieldBoolPairList) { |
|
|
|
private void initColumnProperties(Holder holder, List<Map.Entry<Field, Boolean>> exportFieldBoolPairList) { |
|
|
|
int index = 0; |
|
|
|
int index = 0; |
|
|
|