| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- package xin.glue.ui.B;
- import java.util.List;
- import java.util.Map;
- import xin.glue.ui.common.blob.PosExcelEngine;
- import jxl.Cell;
- import jxl.CellType;
- import jxl.Sheet;
- import jxl.Workbook;
- import jxl.format.Alignment;
- import jxl.format.Border;
- import jxl.format.BorderLineStyle;
- import jxl.format.VerticalAlignment;
- import jxl.write.Label;
- import jxl.write.WritableCellFormat;
- import jxl.write.WritableFont;
- import jxl.write.WritableSheet;
- import jxl.write.WritableWorkbook;
- import jxl.write.WriteException;
- import jxl.write.biff.RowsExceededException;
- public class LGLzkPrint extends PosExcelEngine
- {
- private int TotalCols = 44;//原始38更改为44
- private int TheCols = 43;//原始37改为43
- private String pageCoilNo = null;
- protected void setData(Workbook rwb, WritableWorkbook wb) throws RowsExceededException, WriteException
- {
- Sheet rs = rwb.getSheet(0);//单元
- WritableSheet sheet = wb.getSheet(0); //可编辑单元,即副本
-
- List listHead = (List)dataList.get(0);
- List list = (List)dataList.get(1);
- List listChem = (List)dataList.get(2);//成分
-
- Label label = null;
- Cell cell = null;
-
- int FistRow = 3;//板坯号、重量、规格等填充开始行
- int secondRow = 13;//成分开始填充行
-
- ///车辆号、日期等
- int ZeroRow = 1;
- Map rowx = (Map)listHead.get(0);
- //流水号
- label = new Label(1 , ZeroRow , rowx.get("PRINT_ZH_NO")==null?"":rowx.get("PRINT_ZH_NO").toString() ,sheet.getCell(9 , ZeroRow).getCellFormat() );
- sheet.addCell(label);
- //流向
- label = new Label(9 , ZeroRow , rowx.get("CHAN_XIAN")==null?"":rowx.get("CHAN_XIAN").toString() ,sheet.getCell(9 , ZeroRow).getCellFormat() );
- sheet.addCell(label);
- //车辆号
- label = new Label(12 , ZeroRow , rowx.get("CAR_NO")==null?"":rowx.get("CAR_NO").toString() ,sheet.getCell(12 , ZeroRow).getCellFormat() );
- sheet.addCell(label);
- //发卡日期
- label = new Label(14 , ZeroRow , rowx.get("DATE_")==null?"":rowx.get("DATE_").toString() ,sheet.getCell(14 , ZeroRow).getCellFormat() );
- sheet.addCell(label);
- //打印人
- label = new Label(1 , 20 , rowx.get("REG_NM")==null?"":rowx.get("REG_NM").toString() ,sheet.getCell(1 , 20).getCellFormat() );
- sheet.addCell(label);
-
- //是否需要打印成分
- String needChem = rowx.get("NEED_CHEM").toString();
- if("N".equals(needChem ))
- {
- sheet.removeRow(secondRow-1);
- sheet.insertRow(secondRow-1);
- sheet.removeRow(secondRow-2);
- sheet.insertRow(secondRow-2);
- }
-
- ///板坯号、重量、规格等
- int rowTol = list.size();//查询结果行数
- for(int i =0 ; i< list.size(); i++)
- {
- Map row = (Map)list.get(i);
- for (int curRow = FistRow+i; curRow < FistRow+rowTol; curRow++)
- {
- for(int curCol = 0; curCol < 30; curCol++)
- {
- cell = sheet.getCell(curCol, FistRow-1);
- if(cell.getType() == CellType.EMPTY)continue;
- String conStr = cell.getContents().toString();//第3行
- //System.out.println("SLAB_NO========"+conStr);
- if(!"".equals(conStr) || conStr != null)
- {
- label = new Label(curCol , curRow ,row.get(conStr)==null?"":row.get(conStr).toString());
- sheet.addCell(label);
- }
- }
- }
- }//for end
-
- ///成分
- if("Y".equals(needChem))
- {
- rowTol = listChem.size();//查询结果行数
- for(int i =0 ; i< listChem.size(); i++)//成分
- {
- Map row = (Map)listChem.get(i);
- for (int curRow = secondRow+i; curRow < secondRow+rowTol; curRow++)
- {
- for(int curCol = 0; curCol < 30; curCol++)
- {
- cell = sheet.getCell(curCol, secondRow-1);
- if(cell.getType() == CellType.EMPTY)continue;
- String conStr = cell.getContents().toString().toUpperCase();//元素名,元素名转换为大写
- //System.out.println("CHEM========"+conStr);
- if(!"".equals(conStr) || conStr != null)
- {
- //System.out.println("-------------->"+row.get(conStr)==null?"":row.get(conStr).toString());
- label = new Label(curCol , curRow ,row.get(conStr)==null?"":row.get(conStr).toString());
- sheet.addCell(label);
- }
- }
- }
- }//for end
- }//if end
- }
-
- public void setData()
- {
-
- }
- }
|