| | |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.openxml4j.opc.OPCPackage; |
| | | import org.apache.poi.poifs.filesystem.POIFSFileSystem; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
| | | import org.apache.poi.xssf.usermodel.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | width = 5000; |
| | | } |
| | | // 创建新的Excel 工作簿 |
| | | XSSFWorkbook workbook = new XSSFWorkbook(); |
| | | |
| | | //XSSFWorkbook workbook = new XSSFWorkbook(); |
| | | SXSSFWorkbook workbook = new SXSSFWorkbook(1000); |
| | | |
| | | //合并的单元格样式 |
| | | XSSFCellStyle boderStyle = workbook.createCellStyle(); |
| | | CellStyle boderStyle = workbook.createCellStyle(); |
| | | //垂直居中 |
| | | boderStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); |
| | | boderStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式 |
| | |
| | | // 在Excel工作簿中建一工作表,其名为缺省值 |
| | | // 如要新建一名为"效益指标"的工作表,其语句为: |
| | | // HSSFSheet sheet = workbook.createSheet("效益指标"); |
| | | XSSFSheet sheet = workbook.createSheet(); |
| | | Sheet sheet = workbook.createSheet(); |
| | | // 在索引0的位置创建行(最顶端的行) |
| | | XSSFRow row = sheet.createRow(0); |
| | | Row row = sheet.createRow(0); |
| | | // =============================================================== |
| | | XSSFCell cell; |
| | | Cell cell; |
| | | for (int i = 0; i < headList.length; i++) { |
| | | //高度 |
| | | row.setHeight(height.shortValue()); |
| | |
| | | } |
| | | // =============================================================== |
| | | if (dataList != null) { |
| | | XSSFRow row_value; |
| | | Row row_value; |
| | | Map<String, Object> dataMap; |
| | | for (int n = 0; n < dataList.size(); n++) { |
| | | // 在索引1的位置创建行 |