|
@@ -24,6 +24,7 @@ import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.hibernate.engine.jdbc.Size;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
@@ -1284,7 +1285,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
CellStyle cellStyle2 = workbook.createCellStyle();//设置单元格样式
|
|
|
cellStyle2.setAlignment(HorizontalAlignment.CENTER);//左右居中
|
|
|
cellStyle2.setWrapText(true);//自动换行
|
|
|
- cellStyle2.setFillForegroundColor(IndexedColors.WHITE.getIndex());//设置前景色 现在是浅绿色
|
|
|
+ cellStyle2.setFillForegroundColor(IndexedColors.WHITE.getIndex());//设置前景色 现在是
|
|
|
cellStyle2.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex());//设置背景色 现在是浅绿色
|
|
|
cellStyle2.setBorderBottom(BorderStyle.THIN);//边框
|
|
|
cellStyle2.setBorderTop(BorderStyle.THIN);//边框
|
|
@@ -1293,6 +1294,28 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);//上下居中
|
|
|
cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);//必须设置 否则无效
|
|
|
|
|
|
+ CellStyle cellStyle3 = workbook.createCellStyle();//设置单元格样式
|
|
|
+ cellStyle3.setAlignment(HorizontalAlignment.CENTER);//左右居中
|
|
|
+ cellStyle3.setWrapText(true);//自动换行
|
|
|
+ cellStyle3.setVerticalAlignment(VerticalAlignment.CENTER);//上下居中
|
|
|
+ cellStyle3.setFillForegroundColor(IndexedColors.WHITE.getIndex());//设置前景色 现在是浅绿色
|
|
|
+ cellStyle3.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex());//设置背景色 现在是浅绿色
|
|
|
+ cellStyle3.setBorderBottom(BorderStyle.THIN);//边框
|
|
|
+ cellStyle3.setBorderTop(BorderStyle.THIN);//边框
|
|
|
+ cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);//必须设置 否则无效
|
|
|
+
|
|
|
+
|
|
|
+ CellStyle cellStyle4 = workbook.createCellStyle();//设置单元格样式
|
|
|
+ cellStyle4.setAlignment(HorizontalAlignment.CENTER);//左右居中
|
|
|
+ cellStyle4.setWrapText(true);//自动换行
|
|
|
+ cellStyle4.setVerticalAlignment(VerticalAlignment.CENTER);//上下居中
|
|
|
+ cellStyle4.setFillForegroundColor(IndexedColors.WHITE.getIndex());//设置前景色 现在是浅绿色
|
|
|
+ cellStyle4.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex());//设置背景色 现在是浅绿色
|
|
|
+ cellStyle4.setBorderBottom(BorderStyle.THIN);//边框
|
|
|
+ cellStyle4.setBorderTop(BorderStyle.THIN);//边框
|
|
|
+ cellStyle4.setBorderRight(BorderStyle.THIN);//边框
|
|
|
+ cellStyle4.setFillPattern(FillPatternType.SOLID_FOREGROUND);//必须设置 否则无效
|
|
|
+
|
|
|
Font headerFont = workbook.createFont();
|
|
|
headerFont.setFontHeightInPoints((short) 12);
|
|
|
headerFont.setFontName("黑体");
|
|
@@ -1307,14 +1330,9 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
Sheet sheet=(Sheet) sheets.next();
|
|
|
//箱数、件数、总净重、总体积、总毛重 不需要合计只需要获取主表数据
|
|
|
for (SyPreAssembledPackingList list : items){
|
|
|
- Row row = sheet.createRow(num1+1);
|
|
|
+ int mainLength=num1+1;
|
|
|
+ num1++;
|
|
|
num1++;
|
|
|
- String [] args=list.toString1().split(",");
|
|
|
- for (int i=0;i<args.length;i++){
|
|
|
- Cell cell = row.createCell(i);//横向
|
|
|
- cell.setCellValue(args[i]);
|
|
|
- cell.setCellStyle(cellStyle);
|
|
|
- }
|
|
|
int num2=0;
|
|
|
for (SyPreAssembledPackingListItem item : list.getSyPreAssembledPackingListItemList()){
|
|
|
if(num2==0){
|
|
@@ -1355,34 +1373,121 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
|
|
|
cell.setCellStyle(cellStyle);
|
|
|
}
|
|
|
}
|
|
|
+ //起始行,结束行,起始列,结束列
|
|
|
+ /* String [] args=list.toString1().split(",");
|
|
|
+ Row row = sheet.createRow(mainLength);
|
|
|
+ for (int i=0;i<x;i++){
|
|
|
+ //sheet.createFreezePane();
|
|
|
+ Cell cell = row.createCell(i);//横向
|
|
|
+ if(i<args.length){
|
|
|
+ cell.setCellValue(args[i]);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }else{
|
|
|
+ cell.setCellStyle(cellStyle3);
|
|
|
+ }
|
|
|
+ if(i==x-1){
|
|
|
+ cell.setCellStyle(cellStyle4);
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ // CellRangeAddress region = new CellRangeAddress( 10, 12,10, 12);
|
|
|
+ //sheet.addMergedRegion(region);
|
|
|
+ // Row row = sheet.createRow(mainLength);
|
|
|
+ //Row row3 = sheet.createRow(10);
|
|
|
+ /*Cell cellx = row3.createCell(10);//横向
|
|
|
+ cellx.setCellValue("测试数据");
|
|
|
+ cellx.setCellStyle(cellStyle);*/
|
|
|
+
|
|
|
+ String [] args=list.toString1().split("_____");
|
|
|
+ String [] args1=args[0].split(",");
|
|
|
+ String [] args2=args[1].split(",");
|
|
|
+
|
|
|
+ CellRangeAddress region = new CellRangeAddress( mainLength, mainLength,5, 5+list.getSizeTables().size());
|
|
|
+ sheet.addMergedRegion(region);
|
|
|
+ Row row = sheet.createRow(mainLength);
|
|
|
+ for (int i=0;i<x;i++){
|
|
|
+ //sheet.createFreezePane();
|
|
|
+ Cell cell = row.createCell(i);//横向
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ if(i>5&&i<5+list.getSizeTables().size()+1){
|
|
|
+ Cell cell2= row.createCell(5);
|
|
|
+ cell2.setCellStyle(cellStyle);
|
|
|
+ cell2.setCellValue(args1[5]);
|
|
|
+ continue;
|
|
|
+ }else if(i<5){
|
|
|
+ cell.setCellValue(args1[i]);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }
|
|
|
+ else if(i>5+list.getSizeTables().size()&&i<10+list.getSizeTables().size()){
|
|
|
+ cell.setCellValue(args1[i-list.getSizeTables().size()]);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ cell.setCellStyle(cellStyle3);
|
|
|
+ }
|
|
|
+ if(i==x-1){
|
|
|
+ cell.setCellStyle(cellStyle4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CellRangeAddress region2 = new CellRangeAddress( mainLength+1, mainLength+1,6, 5+list.getSizeTables().size());
|
|
|
+ sheet.addMergedRegion(region2);
|
|
|
+ row = sheet.createRow(mainLength+1);
|
|
|
+ for (int i=0;i<x;i++){
|
|
|
+ Cell cell = row.createCell(i);//横向
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ if(i>6&&i<5+list.getSizeTables().size()){
|
|
|
+ //row.createCell(6).setCellValue("size");
|
|
|
+ Cell cell2= row.createCell(6);
|
|
|
+ cell2.setCellStyle(cellStyle2);
|
|
|
+ cell2.setCellValue("size");
|
|
|
+ continue;
|
|
|
+ }else if(i<6){
|
|
|
+ cell.setCellValue(args2[i]);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }
|
|
|
+ else if(i>5+list.getSizeTables().size()&&i<10+list.getSizeTables().size()){
|
|
|
+ cell.setCellValue(args2[i-list.getSizeTables().size()]);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ cell.setCellStyle(cellStyle3);
|
|
|
+ }
|
|
|
+ if(i==x-1){
|
|
|
+ cell.setCellStyle(cellStyle4);
|
|
|
+ }
|
|
|
+ }
|
|
|
Row row2 = sheet.createRow(num1+1);
|
|
|
+ for (int i=0;i<x;i++){
|
|
|
+ Cell cell = row2.createCell(i);//横向
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ if(i==0){
|
|
|
+ cell.setCellValue("合计");
|
|
|
+ }else if(i==x-10){
|
|
|
+ cell.setCellValue(list.getTotalBoxes().doubleValue());//箱数
|
|
|
+ sheet.setColumnWidth(x-10,list.getTotalVolume().toString().length()*500);
|
|
|
+ }else if(i==x-9){
|
|
|
+ cell.setCellValue(list.getTotal().doubleValue());//总件数
|
|
|
+ sheet.setColumnWidth(x-9,list.getTotal().toString().length()*500);
|
|
|
+ }else if(i==x-5){
|
|
|
+ cell.setCellValue(list.getTotalVolume().doubleValue());//总体积
|
|
|
+ sheet.setColumnWidth(x-9,list.getTotalVolume().toString().length()*500);
|
|
|
+ }else if(i==x-3){
|
|
|
+ cell.setCellValue(list.getTotalNetWeight().doubleValue());//总净重
|
|
|
+ sheet.setColumnWidth(x-9,list.getTotalNetWeight().toString().length()*500);
|
|
|
+ }else if(i==x-1){
|
|
|
+ cell.setCellValue(list.getTotalGrossWeight().doubleValue());//总毛重
|
|
|
+ sheet.setColumnWidth(x-9,list.getTotalGrossWeight().toString().length()*500);
|
|
|
+ }else{
|
|
|
+ cell.setCellStyle(cellStyle3);
|
|
|
+ //cell.setCellValue();//
|
|
|
+ }
|
|
|
+ //sheet.setColumnWidth(x,1000);
|
|
|
+ }
|
|
|
|
|
|
- Cell cell = row2.createCell(0);//横向
|
|
|
- cell.setCellValue("合计");
|
|
|
- cell.setCellStyle(cellStyle);
|
|
|
- Cell cell2 = row2.createCell(x-10);//横向
|
|
|
- cell2.setCellValue(list.getTotalBoxes().doubleValue());//箱数
|
|
|
- sheet.setColumnWidth(x-10,list.getTotalVolume().toString().length()*500);
|
|
|
- cell2.setCellStyle(cellStyle);
|
|
|
- Cell cell3 = row2.createCell(x-9);//横向
|
|
|
- cell3.setCellValue(list.getTotal().doubleValue());//总件数
|
|
|
- sheet.setColumnWidth(x-9,list.getTotalVolume().toString().length()*500);
|
|
|
- cell3.setCellStyle(cellStyle);
|
|
|
- Cell cell4 = row2.createCell(x-5);//横向
|
|
|
- cell4.setCellValue(list.getTotalVolume().doubleValue());//总体积
|
|
|
- sheet.setColumnWidth(x-5,list.getTotalVolume().toString().length()*500);
|
|
|
- cell4.setCellStyle(cellStyle);
|
|
|
- Cell cell5 = row2.createCell(x-3);//横向
|
|
|
- cell5.setCellValue(list.getTotalNetWeight().doubleValue());//总净重
|
|
|
- sheet.setColumnWidth(x-3,list.getTotalNetWeight().toString().length()*500);
|
|
|
- cell5.setCellStyle(cellStyle);
|
|
|
- Cell cell6 = row2.createCell(x-1);//横向
|
|
|
- cell6.setCellValue(list.getTotalGrossWeight().doubleValue());//总毛重
|
|
|
- sheet.setColumnWidth(x-1,list.getTotalGrossWeight().toString().length()*500);
|
|
|
- cell6.setCellStyle(cellStyle);
|
|
|
+ //cell6.setCellStyle(cellStyle);
|
|
|
num1++;
|
|
|
num1++;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|