huminmin
2026-04-23 ef755a24517a15e602b137820a3c60e19b288a9d
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -240,7 +240,6 @@
            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) {
@@ -252,9 +251,8 @@
                sheet.setColumnWidth(3, 2500);
                sheet.setColumnWidth(4, 3000);
                sheet.setColumnWidth(5, 4500);
                sheet.setColumnWidth(6, 3500);
                sheet.setColumnWidth(6, 2000);
                // 样式
                CellStyle companyTitle = createBaseStyle(workbook, "宋体", (short) 20, true, true);
                CellStyle billTitle = createBaseStyle(workbook, "宋体", (short) 18, true, true);
                CellStyle headerStyle = createBorderStyle(workbook, "宋体", (short) 12, true, true);
@@ -294,17 +292,20 @@
                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);
                    }
                }
                // 查询商品
                SalesLedgerProduct cond = new SalesLedgerProduct();
                cond.setSalesLedgerId(ledger.getId());
                List<SalesLedgerProduct> productList = salesLedgerProductServiceImpl.selectSalesLedgerProductList(cond);
@@ -319,7 +320,6 @@
                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);
@@ -354,7 +354,12 @@
                    Cell fourCell = dataRow.createCell(6);
                    if (i < fourNames.length) {
                        fourCell.setCellValue(fourNames[i]);
                        fourCell.setCellStyle(dashStyle);
                        if (i == 0 || i == 1 || i == 2) {
                            fourCell.setCellStyle(dashStyle);
                        } else {
                            fourCell.setCellStyle(noBorder);
                        }
                    } else {
                        fourCell.setCellStyle(noBorder);
                    }
@@ -392,7 +397,7 @@
        } catch (Exception e) {
            log.error("批量导出送货单异常", e);
            throw new BaseException("批量导出失败");
            throw new BaseException("导出失败");
        }
    }