Commit fc8c3f08 by 胡懿

修改出库报错的问题,升级poi,

parent 44111b1e
...@@ -154,13 +154,13 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -154,13 +154,13 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
* */ * */
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void lowerLedger(Ledger ledger) { public void lowerLedger(Ledger ledger) {
List<String> shelvesListByLedgerId = mapper.findShelvesListByLedgerId(ledger.getId()); /*List<String> shelvesListByLedgerId = mapper.findShelvesListByLedgerId(ledger.getId());
if(shelvesListByLedgerId == null || shelvesListByLedgerId.size() == 0){ if(shelvesListByLedgerId == null || shelvesListByLedgerId.size() == 0){
ledger.setShelvesIds(null); ledger.setShelvesIds(null);
}else { }else {
String shelvesIds = String.join(",", shelvesListByLedgerId); String shelvesIds = String.join(",", shelvesListByLedgerId);
ledger.setShelvesIds(shelvesIds); ledger.setShelvesIds(shelvesIds);
} }*/
mapper.update(ledger); mapper.update(ledger);
} }
@Transactional(readOnly = false) @Transactional(readOnly = false)
...@@ -205,7 +205,9 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -205,7 +205,9 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
// 创建工作表 // 创建工作表
XSSFSheet sheet = workbook.createSheet("被装物资库房帐"); XSSFSheet sheet = workbook.createSheet("被装物资库房帐");
CellStyle oneStyle = ExcelStyleUtils.topOneCellStyle(workbook);
CellStyle twoStyle = ExcelStyleUtils.topTwoCellStyle(workbook);
CellStyle threeStyle = ExcelStyleUtils.topThreeCellStyle(workbook);
...@@ -214,60 +216,104 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -214,60 +216,104 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
XSSFRow sheetRow = sheet.createRow(row); XSSFRow sheetRow = sheet.createRow(row);
if (0 == row) { if (0 == row) {
sheetRow.setHeightInPoints(30); sheetRow.setHeightInPoints(30);
XSSFCell cell = sheetRow.createCell(0); for (int i = 0; i < 22; i ++) {
cell.setCellValue("被 装 物 资 库 房 帐"); if (0 == i) {
cell.setCellStyle(ExcelStyleUtils.topOneCellStyle(workbook)); XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("被 装 物 资 库 房 帐");
cell.setCellStyle(oneStyle);
} else {
XSSFCell cell = sheetRow.createCell(i);
cell.setCellStyle(oneStyle);
}
}
} }
if (1 == row) { if (1 == row) {
sheetRow.setHeightInPoints(20); sheetRow.setHeightInPoints(20);
XSSFCell cell = sheetRow.createCell(0); for (int i = 0; i < 22; i ++) {
cell.setCellValue("品名代码:" + materialType.getCode()); if (0 == i) {
cell.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook)); XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("品名代码:" + materialType.getCode());
XSSFCell cell1 = sheetRow.createCell(4); cell.setCellStyle(twoStyle);
cell1.setCellValue("品名:" + materialType.getName()); } else if (4 == i) {
cell1.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook)); XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue("品名:" + materialType.getName());
cell1.setCellStyle(twoStyle);
} else if (12 == i) {
XSSFCell cell2 = sheetRow.createCell(i);
cell2.setCellValue("计量单位:" + materialType.getUnit());
cell2.setCellStyle(twoStyle);
} else {
XSSFCell cell2 = sheetRow.createCell(i);
cell2.setCellStyle(twoStyle);
}
}
XSSFCell cell2 = sheetRow.createCell(12);
cell2.setCellValue("计量单位:" + materialType.getUnit());
cell2.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook));
} }
if (2 == row) { if (2 == row) {
sheetRow.setHeightInPoints(20); sheetRow.setHeightInPoints(15);
XSSFCell cell = sheetRow.createCell(0); for (int i = 0; i < 22; i ++) {
cell.setCellValue(DateUtil.getYear(eTime) + " 年"); if (0 == i) {
cell.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook)); XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue(DateUtil.getYear(eTime) + " 年");
sheetRow.setHeightInPoints(20); cell.setCellStyle(threeStyle);
XSSFCell cell1 = sheetRow.createCell(2);
cell1.setCellValue("凭证批号"); } else if (2 == i) {
cell1.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook)); XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue("凭证批号");
sheetRow.setHeightInPoints(20); cell1.setCellStyle(threeStyle);
XSSFCell cell2 = sheetRow.createCell(3); } else if (3 == i) {
cell2.setCellValue("摘要"); XSSFCell cell2 = sheetRow.createCell(i);
cell2.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook)); cell2.setCellValue("摘要");
cell2.setCellStyle(threeStyle);
sheetRow.setHeightInPoints(20); } else if (4 == i) {
XSSFCell cell3 = sheetRow.createCell(4); XSSFCell cell3 = sheetRow.createCell(i);
cell3.setCellValue("收入"); cell3.setCellValue("收入");
cell3.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook)); cell3.setCellStyle(threeStyle);
} else if (5 == i) {
sheetRow.setHeightInPoints(20); XSSFCell cell4 = sheetRow.createCell(i);
XSSFCell cell4 = sheetRow.createCell(5); cell4.setCellValue("支出");
cell4.setCellValue("支出"); cell4.setCellStyle(threeStyle);
cell4.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook)); } else if (6 == i) {
XSSFCell cell5 = sheetRow.createCell(i);
cell5.setCellValue("结存");
cell5.setCellStyle(threeStyle);
} else if (21 == i) {
XSSFCell cell6 = sheetRow.createCell(i);
cell6.setCellValue("摘要");
cell6.setCellStyle(threeStyle);
} else {
XSSFCell cell6 = sheetRow.createCell(i);
cell6.setCellStyle(threeStyle);
}
}
}
if (3 == row) {
sheetRow.setHeightInPoints(15);
for (int i = 0; i < 22; i ++) {
if (0 == i) {
XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("月");
cell.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else if (1 == i) {
XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue("日");
cell1.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else if (6 == i) {
XSSFCell cell2 = sheetRow.createCell(i);
cell2.setCellValue("数量");
cell2.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else if (7 == i) {
XSSFCell cell3 = sheetRow.createCell(i);
cell3.setCellValue("号型");
cell3.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else {
XSSFCell cell3 = sheetRow.createCell(i);
cell3.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
}
}
sheetRow.setHeightInPoints(20);
XSSFCell cell5 = sheetRow.createCell(6);
cell5.setCellValue("结存");
cell5.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook));
sheetRow.setHeightInPoints(20);
XSSFCell cell6 = sheetRow.createCell(21);
cell6.setCellValue("摘要");
cell6.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook));
} }
// 设置列宽 sheet.setColumnWidth(0, 16 * 256); 第一个参数为第几个单元格,第二个为16个字符宽度 // 设置列宽 sheet.setColumnWidth(0, 16 * 256); 第一个参数为第几个单元格,第二个为16个字符宽度
} }
...@@ -283,6 +329,9 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -283,6 +329,9 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
sheet.addMergedRegion(new CellRangeAddress(2,4,5,5)); sheet.addMergedRegion(new CellRangeAddress(2,4,5,5));
sheet.addMergedRegion(new CellRangeAddress(2,2,6,20)); sheet.addMergedRegion(new CellRangeAddress(2,2,6,20));
sheet.addMergedRegion(new CellRangeAddress(2,4,21,21)); sheet.addMergedRegion(new CellRangeAddress(2,4,21,21));
sheet.addMergedRegion(new CellRangeAddress(3,4,6,6));
sheet.addMergedRegion(new CellRangeAddress(3,3,7,20));
FileOutputStream out = null; FileOutputStream out = null;
try { try {
out = new FileOutputStream(new File("D:/excel.xlsx")); out = new FileOutputStream(new File("D:/excel.xlsx"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment