刚刚试了下使用GCExcel来处理这个功能,
先将Excel转为ssjson传到后端,利用GCExcel来设置复选框,没发现崩溃
目前GCExcel也能实现该功能,那这个问题也不是很急了,感谢~
- Workbook workbook = new Workbook();
- workbook.fromJson(templateContent);
- IWorksheet worksheet = workbook.getWorksheets().get(0);
- // 项目阶段在第三行
- // 先清空第三行的合并单元格,以及内容
- int columnCount = worksheet.getColumnCount();
- // 将该行的合并单元格去掉,并且清除内容,并且去掉顶部的边框
- IRange range = worksheet.getRange(2, 0, 1, columnCount);
- range.merge();
- range.getBorders().get(BordersIndex.EdgeTop).setLineStyle(BorderLineStyle.None);
- range.setValue(null);range.unmerge();
- worksheet.getRange(2, 0).setValue("项目阶段:");
- // 复选框列表
- CheckBoxListCellType checkBoxListCellType = new CheckBoxListCellType();
- ArrayList<SelectFieldItem> items = checkBoxListCellType.getItems();
- // 样件,试生产,生产
- SelectFieldItem selectFieldItem = new SelectFieldItem();
- selectFieldItem.setText("样件");selectFieldItem.setValue(1);
- items.add(selectFieldItem);
- SelectFieldItem selectFieldItem1 = new SelectFieldItem();
- selectFieldItem1.setText("试生产");selectFieldItem1.setValue(2);
- items.add(selectFieldItem1);
- SelectFieldItem selectFieldItem2 = new SelectFieldItem();
- selectFieldItem2.setText("生产");selectFieldItem2.setValue(3);
- items.add(selectFieldItem2);
- // 占用四列,设置为复选框类型
- IRange range1 = worksheet.getRange(2, 1, 1, 4);
- range1.merge();range1.setHorizontalAlignment(HorizontalAlignment.Left);
- range1.setCellType(checkBoxListCellType);range1.setValue(null);
复制代码
|