<> Problem description

com.alibaba.excel.exception.ExcelDataConvertException: Can not find
‘Converter’ support class List.

<> Problem explanation

EasyExcel In the open source framework Converter Interfaced convertToExcelData Only conversion is implemented BigDecimal,Bolean,Byte[],btye[],Byte,Date,Double,File,Float,InputStream,Integer,Long,Short,URL These types , Means parameter data It can only be two-dimensional data at most , But the business logic needs to be transformed this time List<
String > Data of .

<> Entity class data
/** * Name of the enterprise under the name */ @ExcelProperty(value = " Name of the enterprise under the name ",index = 12) private
List<String> enterpriseList;
<> terms of settlement

Write custom Converter converter :
@Component public class ListConverter implements Converter<List> { @Override
public Class supportJavaTypeKey() { return List.class; } @Override public
CellDataTypeEnum supportExcelTypeKey() { return CellDataTypeEnum.STRING; }
@Override public List convertToJavaData(CellData cellData, ExcelContentProperty
excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception
{ String stringValue = cellData.getStringValue(); String[] split =
stringValue.split(","); List<String> enterpriseList = new ArrayList<>();
for(int i = 0; i < split.length; i++){ enterpriseList.add(split[i]); } return
enterpriseList; } @Override public CellData convertToExcelData(List list,
ExcelContentProperty excelContentProperty, GlobalConfiguration
globalConfiguration) throws Exception { StringBuilder stringBuilder = new
StringBuilder(); list.forEach(o -> { String s = o.toString();
stringBuilder.append(s+","); }); return new CellData(stringBuilder.toString());
} }

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?