| | |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | |
| | | // 固定使用 XSSFWorkbook |
| | | XSSFWorkbook workbook = new XSSFWorkbook(); |
| | | |
| | | for (SalesLedger ledger : ledgerList) { |
| | |
| | | sheet.setColumnWidth(5, 4500); |
| | | sheet.setColumnWidth(6, 3500); |
| | | |
| | | // 样式 |
| | | CellStyle companyTitle = createBaseStyle(workbook, "宋体", (short) 20, true, true); |
| | | CellStyle billTitle = createBaseStyle(workbook, "宋体", (short) 18, true, true); |
| | | CellStyle headerStyle = createBorderStyle(workbook, "宋体", (short) 12, true, true); |
| | |
| | | Row row7 = sheet.createRow(7); |
| | | row7.createCell(0).setCellValue("货物详细信息:"); |
| | | |
| | | // 表头 |
| | | int tableStart = 8; |
| | | Row headerRow = sheet.createRow(tableStart); |
| | | String[] headers = {"序号", "物料编号", "品名/规格", "单位", "数量", "订单号", "共四联"}; |
| | | for (int i = 0; i < headers.length; i++) { |
| | | Cell hc = headerRow.createCell(i); |
| | | hc.setCellValue(headers[i]); |
| | | hc.setCellStyle(i == 6 ? noBorder : headerStyle); |
| | | if (i == 6) { |
| | | hc.setCellStyle(dashStyle); |
| | | } else { |
| | | hc.setCellStyle(headerStyle); |
| | | } |
| | | } |
| | | |
| | | // 查询商品 |
| | |
| | | int minDataRow = 5; |
| | | int totalNeedRow = Math.max(minDataRow, fourNames.length); |
| | | |
| | | // 数据行 + 固定四联行 |
| | | for (int i = 0; i < totalNeedRow; i++) { |
| | | SalesLedgerProduct p = i < productList.size() ? productList.get(i) : null; |
| | | Row dataRow = sheet.createRow(currentRow); |
| | | |
| | | // 前6列赋值 |
| | | // 前6列 |
| | | if (p != null) { |
| | | String materialCode = ""; |
| | | if (p.getProductModelId() != null) { |
| | |
| | | dataRow.getCell(c).setCellStyle(dataCenterStyle); |
| | | } |
| | | |
| | | // 共四联列 |
| | | // 第7列:共四联区域 |
| | | Cell fourCell = dataRow.createCell(6); |
| | | if (i < fourNames.length) { |
| | | fourCell.setCellValue(fourNames[i]); |