|
|
@ -428,10 +428,7 @@ public class ExcelTemplateALPHA { |
|
|
style.setBorderBottom(BorderStyle.NONE); |
|
|
style.setBorderBottom(BorderStyle.NONE); |
|
|
style.setBorderTop(BorderStyle.NONE); |
|
|
style.setBorderTop(BorderStyle.NONE); |
|
|
style.setWrapText(true); |
|
|
style.setWrapText(true); |
|
|
// 箱单 A 列 CTN No 后面会单独居中;这里不要改共享样式的对齐,避免表头被带成左对齐 |
|
|
|
|
|
if (!(intRight && j == 0)) { |
|
|
|
|
|
style.setAlignment(HorizontalAlignment.LEFT); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
style.setAlignment(HorizontalAlignment.LEFT); |
|
|
c.setCellStyle(style); |
|
|
c.setCellStyle(style); |
|
|
if (rangeStyle && j < 4) { |
|
|
if (rangeStyle && j < 4) { |
|
|
for (int mi = 0; mi < 3; mi++) { |
|
|
for (int mi = 0; mi < 3; mi++) { |
|
|
@ -447,23 +444,6 @@ public class ExcelTemplateALPHA { |
|
|
} |
|
|
} |
|
|
// 设置明细样式,因为明细是动态添加的,会有样式和模版偏差,此处主要是第2、3列的样式需要设置 |
|
|
// 设置明细样式,因为明细是动态添加的,会有样式和模版偏差,此处主要是第2、3列的样式需要设置 |
|
|
if (cellStyle) { |
|
|
if (cellStyle) { |
|
|
// 箱单 A 列 CTN No 共用一份居中样式:箱号/托号是文本(如 1~1),不在数字列循环里。 |
|
|
|
|
|
// 明细默认左对齐,RFID 的 c1 还会重绘 A 列;循环后再覆盖,后续合并才能 clone 到居中。 |
|
|
|
|
|
XSSFCellStyle packingCtnNoStyle = null; |
|
|
|
|
|
if (intRight) { |
|
|
|
|
|
packingCtnNoStyle = workbook.createCellStyle(); |
|
|
|
|
|
packingCtnNoStyle.setBorderRight(BorderStyle.NONE); |
|
|
|
|
|
packingCtnNoStyle.setBorderLeft(BorderStyle.MEDIUM); |
|
|
|
|
|
packingCtnNoStyle.setBorderBottom(BorderStyle.NONE); |
|
|
|
|
|
packingCtnNoStyle.setBorderTop(BorderStyle.NONE); |
|
|
|
|
|
Font packingCtnNoFont = workbook.createFont(); |
|
|
|
|
|
packingCtnNoFont.setFontName("Arial"); |
|
|
|
|
|
packingCtnNoFont.setFontHeightInPoints((short) 10); |
|
|
|
|
|
packingCtnNoStyle.setFont(packingCtnNoFont); |
|
|
|
|
|
packingCtnNoStyle.setVerticalAlignment(VerticalAlignment.TOP); |
|
|
|
|
|
packingCtnNoStyle.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
|
packingCtnNoStyle.setWrapText(true); |
|
|
|
|
|
} |
|
|
|
|
|
for (Integer dtlRow : dtlRows) { |
|
|
for (Integer dtlRow : dtlRows) { |
|
|
XSSFCell c1 = sheet.getRow(dtlRow).getCell(cellStyle2?0:1); |
|
|
XSSFCell c1 = sheet.getRow(dtlRow).getCell(cellStyle2?0:1); |
|
|
if (c1 == null) { |
|
|
if (c1 == null) { |
|
|
@ -624,6 +604,16 @@ public class ExcelTemplateALPHA { |
|
|
c7.setCellStyle(style7); |
|
|
c7.setCellStyle(style7); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 列表第一列 CTN No 居中(数字列从第5列才开始处理) |
|
|
|
|
|
XSSFRow packingRow = sheet.getRow(dtlRow); |
|
|
|
|
|
XSSFCell firstCol = packingRow == null ? null : packingRow.getCell(0); |
|
|
|
|
|
if (firstCol != null) { |
|
|
|
|
|
XSSFCellStyle firstColStyle = workbook.createCellStyle(); |
|
|
|
|
|
firstColStyle.cloneStyleFrom(firstCol.getCellStyle()); |
|
|
|
|
|
firstColStyle.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
|
firstCol.setCellStyle(firstColStyle); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// net_weight列(J列,索引9)保持顶部右对齐 |
|
|
// net_weight列(J列,索引9)保持顶部右对齐 |
|
|
/*XSSFRow row = sheet.getRow(dtlRow); |
|
|
/*XSSFRow row = sheet.getRow(dtlRow); |
|
|
if (row != null) { |
|
|
if (row != null) { |
|
|
@ -638,19 +628,6 @@ public class ExcelTemplateALPHA { |
|
|
}*/ |
|
|
}*/ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 放在明细样式循环之后,覆盖 RFID/Label 对 A 列的默认左对齐,再交给后续合并 clone |
|
|
|
|
|
if (packingCtnNoStyle != null && dtlRowIndex >= 0 && !listVariables.isEmpty()) { |
|
|
|
|
|
for (int r = dtlRowIndex; r < dtlRowIndex + listVariables.size(); r++) { |
|
|
|
|
|
XSSFRow ctnRow = sheet.getRow(r); |
|
|
|
|
|
if (ctnRow == null) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
XSSFCell ctnNoCell = ctnRow.getCell(0); |
|
|
|
|
|
if (ctnNoCell != null) { |
|
|
|
|
|
ctnNoCell.setCellStyle(packingCtnNoStyle); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
if (delRight) { |
|
|
if (delRight) { |
|
|
int declarationCenterStartCol = declarationUnitPriceCols.isEmpty() |
|
|
int declarationCenterStartCol = declarationUnitPriceCols.isEmpty() |
|
|
|