diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java index e796ec7..2f9f736 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java @@ -10,9 +10,7 @@ import com.jfinal.kit.StrKit; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.ArrayList; @@ -190,6 +188,7 @@ public class InvoiceLogService extends BaseService { row.createCell(a++).setCellValue("毛重(吨)"); // 表头 end + int end_col = 16; int datalen = list.size(); for (int i = 0; i < datalen; i++) { Record order = list.get(i); @@ -223,6 +222,32 @@ public class InvoiceLogService extends BaseService { row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "second_weight")); } + // 通用单元格格式 + Font font = wb.createFont(); + CellStyle cellStyle = wb.createCellStyle(); + font.setFontHeight((short) (10 * 20)); + font.setFontName("宋体"); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle.setFont(font); + + // 设置通用单元格格式 + for (int r = 0; r < datalen + 1; r++) { + row = sheet.getRow(r); + if (row == null) { + row = sheet.createRow(r); + } + + for (int c = 0; c < end_col + 1; c++) { + Cell cell = row.getCell(c); + + if (cell == null) { + cell = row.createCell(c); + } + cell.setCellStyle(cellStyle); + } + } + return wb; } } diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java index 5168976..50234ca 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java @@ -14,9 +14,7 @@ import com.jfinal.kit.StrKit; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.ArrayList; @@ -294,6 +292,7 @@ public class OrderTempService extends BaseService { row.createCell(a++).setCellValue("开票人"); // 表头 end + int end_col = 15; int datalen = list.size(); for (int i = 0; i < datalen; i++) { Record order = list.get(i); @@ -330,6 +329,32 @@ public class OrderTempService extends BaseService { row.createCell(a++).setCellValue(order.getStr("settlement_user_name")); } + // 通用单元格格式 + Font font = wb.createFont(); + CellStyle cellStyle = wb.createCellStyle(); + font.setFontHeight((short) (10 * 20)); + font.setFontName("宋体"); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle.setFont(font); + + // 设置通用单元格格式 + for (int r = 0; r < datalen + 1; r++) { + row = sheet.getRow(r); + if (row == null) { + row = sheet.createRow(r); + } + + for (int c = 0; c < end_col + 1; c++) { + Cell cell = row.getCell(c); + + if (cell == null) { + cell = row.createCell(c); + } + cell.setCellStyle(cellStyle); + } + } + return wb; } }