Browse Source

第一列ctn no全部居中

ecss-tx
han\hanst 2 weeks ago
parent
commit
cb3e3f00cc
  1. 35
      src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java
  2. 11
      src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java

35
src/main/java/com/xujie/sys/common/utils/ExcelTemplateALPHA.java

@ -428,7 +428,10 @@ 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);
style.setAlignment(HorizontalAlignment.LEFT);
// 箱单 A CTN No 后面会单独居中这里不要改共享样式的对齐避免表头被带成左对齐
if (!(intRight && j == 0)) {
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++) {
@ -444,6 +447,23 @@ public class ExcelTemplateALPHA {
} }
// 设置明细样式因为明细是动态添加的会有样式和模版偏差此处主要是第23列的样式需要设置 // 设置明细样式因为明细是动态添加的会有样式和模版偏差此处主要是第23列的样式需要设置
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) {
@ -618,6 +638,19 @@ 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()

11
src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java

@ -3166,12 +3166,13 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
template.addMergeRegion(boxStartIndex, boxEndIndex, 9); template.addMergeRegion(boxStartIndex, boxEndIndex, 9);
// 毛重列K列索引10 // 毛重列K列索引10
template.addMergeRegion(boxStartIndex, boxEndIndex, 10); template.addMergeRegion(boxStartIndex, boxEndIndex, 10);
// 无托时 A 列是箱号单行也注册合并样式保证 CTN No 水平居中合箱再纵向合并
if (!hasPalletData) {
template.addMergeRegion(boxStartIndex, boxEndIndex, 0, 2);
}
// 合箱F列箱数按箱合并居中有托时A列仍是托号不能按箱合并A列 // 合箱F列箱数按箱合并居中有托时A列仍是托号不能按箱合并A列
if (boxEndIndex > boxStartIndex) { if (boxEndIndex > boxStartIndex) {
template.addMergeRegion(boxStartIndex, boxEndIndex, 5); template.addMergeRegion(boxStartIndex, boxEndIndex, 5);
if (!hasPalletData) {
template.addMergeRegion(boxStartIndex, boxEndIndex, 0);
}
} }
} }
// 托盘数列按托盘(seq_no)跨箱合并一个托盘下多个箱共享同一托盘数 // 托盘数列按托盘(seq_no)跨箱合并一个托盘下多个箱共享同一托盘数
@ -3182,9 +3183,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService {
} }
boolean isCurrentPalletEnd = (m == list.size() - 1) || !Objects.equals(palletSeqNo, nextPalletSeqNo); boolean isCurrentPalletEnd = (m == list.size() - 1) || !Objects.equals(palletSeqNo, nextPalletSeqNo);
if (isCurrentPalletEnd && palletStartIndex >= 0 && boxEndIndex >= palletStartIndex) { if (isCurrentPalletEnd && palletStartIndex >= 0 && boxEndIndex >= palletStartIndex) {
// 第一列托号按托盘合并一个托可能有多个箱
// 第一列托号按托盘合并一个托可能有多个箱alignType=2 水平居中
if (hasPalletData) { if (hasPalletData) {
template.addMergeRegion(palletStartIndex, boxEndIndex, 0);
template.addMergeRegion(palletStartIndex, boxEndIndex, 0, 2);
} }
// 托盘列倒数第3列索引6按托盘合并 // 托盘列倒数第3列索引6按托盘合并
template.addMergeRegion(palletStartIndex, boxEndIndex, 8); template.addMergeRegion(palletStartIndex, boxEndIndex, 8);

Loading…
Cancel
Save