jxls - 多行(列表)绑定不起作用
jxls - multiple row (list) binding doesn't work
我正在尝试使用 jxls 库创建 excel 表单。
我的 excel 模板是:
当我将一张地图添加到列表中并绑定它时,它起作用了。
我的代码很简单:
List<Map<String,Object>> sss = new ArrayList();
HashMap<String,Object> sm = new HashMap<String,Object>();
sm.put("name1", "AtestName");
sm.put("name2", "AtestName2");
sm.put("name3", "AtestName3");
sss.add(sm);
Map<String, Object> model = new HashMap<String,Object>();
model.put("sData", sss);
.... XLSTransformer transformer = new XLSTransformer(); .....
但是当我将多个地图添加到列表并绑定它时,它无法抛出异常。
听说jxls库自动识别列表。
我在做什么?
List<Map<String,Object>> sss = new ArrayList();
HashMap<String,Object> sm = new HashMap<String,Object>();
sm.put("name1", "AtestName");
sm.put("name2", "AtestName2");
sm.put("name3", "AtestName3");
sss.add(sm);
HashMap<String,Object> sm2 = new HashMap<String,Object>();
sm.put("name1", "BtestName");
sm.put("name2", "BtestName2");
sm.put("name3", "BtestName3");
sss.add(sm2);
HashMap<String,Object> sm3 = new HashMap<String,Object>();
sm.put("name1", "CtestName");
sm.put("name2", "CtestName2");
sm.put("name3", "CtestName3");
sss.add(sm3);
Map<String, Object> model = new HashMap<String,Object>();
model.put("sData", sss);
.... XLSTransformer transformer = new XLSTransformer(); .....
[ 06:15:10] DEBUG - AbstractExcelView.renderMergedOutputModel(140) | Created Excel Workbook from scratch
[ 06:15:10] DEBUG - SheetTransformer.transformSheet(72) | Processing sheet: Sheet1
[ 06:15:10] DEBUG - CollectionRowTransformer.processRowCollections(96) | ----collection-property--------->sData
, 2016 6:15:10 오후 org.apache.catalina.core.StandardWrapperValve invoke
: Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Sheet.getSheetConditionalFormatting()Lorg/apache/poi/ss/usermodel/SheetConditionalFormatting;
at net.sf.jxls.util.Util.copyConditionalFormat(Util.java:642)
at net.sf.jxls.util.Util.copyCell(Util.java:569)
at net.sf.jxls.util.Util.duplicateStyle(Util.java:411)
at net.sf.jxls.util.Util.duplicateRow(Util.java:244)
at net.sf.jxls.controller.SheetTransformationControllerImpl.duplicateRow(SheetTransformationControllerImpl.java:140)
at net.sf.jxls.transformer.CollectionRowTransformer.processRowCollections(CollectionRowTransformer.java:106)
at net.sf.jxls.transformer.CollectionRowTransformer.transform(CollectionRowTransformer.java:66)
at net.sf.jxls.transformer.SheetTransformer.transformSheet(SheetTransformer.java:88)
at net.sf.jxls.transformer.XLSTransformer.transformWorkbook(XLSTransformer.java:248)
at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:221)
您收到的错误 java.lang.NoSuchMethodError:org.apache.poi.ss.usermodel.Sheet.getSheetConditionalFormatting
很可能意味着您的 POI 版本有问题。
所以请检查您使用的 Apache POI 版本以及它是否支持 Sheet.getSheetConditionalFormatting()
方法
我正在尝试使用 jxls 库创建 excel 表单。
我的 excel 模板是:
当我将一张地图添加到列表中并绑定它时,它起作用了。 我的代码很简单:
List<Map<String,Object>> sss = new ArrayList();
HashMap<String,Object> sm = new HashMap<String,Object>();
sm.put("name1", "AtestName");
sm.put("name2", "AtestName2");
sm.put("name3", "AtestName3");
sss.add(sm);
Map<String, Object> model = new HashMap<String,Object>();
model.put("sData", sss);
.... XLSTransformer transformer = new XLSTransformer(); .....
但是当我将多个地图添加到列表并绑定它时,它无法抛出异常。 听说jxls库自动识别列表。 我在做什么?
List<Map<String,Object>> sss = new ArrayList();
HashMap<String,Object> sm = new HashMap<String,Object>();
sm.put("name1", "AtestName");
sm.put("name2", "AtestName2");
sm.put("name3", "AtestName3");
sss.add(sm);
HashMap<String,Object> sm2 = new HashMap<String,Object>();
sm.put("name1", "BtestName");
sm.put("name2", "BtestName2");
sm.put("name3", "BtestName3");
sss.add(sm2);
HashMap<String,Object> sm3 = new HashMap<String,Object>();
sm.put("name1", "CtestName");
sm.put("name2", "CtestName2");
sm.put("name3", "CtestName3");
sss.add(sm3);
Map<String, Object> model = new HashMap<String,Object>();
model.put("sData", sss);
.... XLSTransformer transformer = new XLSTransformer(); .....
[ 06:15:10] DEBUG - AbstractExcelView.renderMergedOutputModel(140) | Created Excel Workbook from scratch
[ 06:15:10] DEBUG - SheetTransformer.transformSheet(72) | Processing sheet: Sheet1
[ 06:15:10] DEBUG - CollectionRowTransformer.processRowCollections(96) | ----collection-property--------->sData
, 2016 6:15:10 오후 org.apache.catalina.core.StandardWrapperValve invoke
: Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Sheet.getSheetConditionalFormatting()Lorg/apache/poi/ss/usermodel/SheetConditionalFormatting;
at net.sf.jxls.util.Util.copyConditionalFormat(Util.java:642)
at net.sf.jxls.util.Util.copyCell(Util.java:569)
at net.sf.jxls.util.Util.duplicateStyle(Util.java:411)
at net.sf.jxls.util.Util.duplicateRow(Util.java:244)
at net.sf.jxls.controller.SheetTransformationControllerImpl.duplicateRow(SheetTransformationControllerImpl.java:140)
at net.sf.jxls.transformer.CollectionRowTransformer.processRowCollections(CollectionRowTransformer.java:106)
at net.sf.jxls.transformer.CollectionRowTransformer.transform(CollectionRowTransformer.java:66)
at net.sf.jxls.transformer.SheetTransformer.transformSheet(SheetTransformer.java:88)
at net.sf.jxls.transformer.XLSTransformer.transformWorkbook(XLSTransformer.java:248)
at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:221)
您收到的错误 java.lang.NoSuchMethodError:org.apache.poi.ss.usermodel.Sheet.getSheetConditionalFormatting
很可能意味着您的 POI 版本有问题。
所以请检查您使用的 Apache POI 版本以及它是否支持 Sheet.getSheetConditionalFormatting()
方法