| | |
| | | package com.vci.starter.poi.util; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.vci.starter.poi.annotation.ExcelColumn; |
| | | import com.vci.starter.poi.annotation.ExcelTitle; |
| | | import com.vci.starter.poi.bo.*; |
| | |
| | | //写值 |
| | | setCellValue(cell, value); |
| | | } |
| | | //设置自适应列宽 |
| | | sheet.autoSizeColumn(ed.getCol()); |
| | | if(ed.getWidth()!=null && ed.getWidth()>0){ |
| | | sheet.setColumnWidth(cell.getColumnIndex(),(int)(ed.getWidth() + 0.72)*256); |
| | | } |
| | |
| | | if (ed.getColTo() < ed.getCol()) { |
| | | ed.setColTo(ed.getCol()); |
| | | } |
| | | List<CellRangeAddress> cellRangeAddressList = sheet.getMergedRegions(); |
| | | sheet.addMergedRegion(new CellRangeAddress(ed.getRow(), ed.getRowTo(), ed.getCol(), ed.getColTo())); |
| | | }); |
| | | } |
| | |
| | | * @return 数据列表 |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | public static List<SheetDataSet> readDataObjectFromExcel(File file) throws VciBaseException { |
| | | public static List<SheetDataSet> readDataObjectFromExcel(File file) throws VciBaseException { |
| | | return readDataObjectFromExcel(file, SheetDataSet.class); |
| | | } |
| | | |
| | |
| | | try { |
| | | for (int sheetIndex = 0; sheetIndex < workbook.getNumberOfSheets(); sheetIndex++) { |
| | | Sheet sheet = workbook.getSheetAt(sheetIndex); |
| | | String sheetName=sheet.getSheetName(); |
| | | if(StringUtils.isNotBlank(excelOption.getSheetName())){ |
| | | if(!sheet.getSheetName().equalsIgnoreCase(excelOption.getSheetName())){ |
| | | continue; |