cbf4bcb5b8b5f654e44a682625c11e4dffb9ab7a.svn-base 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package xin.glue.ui.B;
  2. import java.util.List;
  3. import java.util.Map;
  4. import xin.glue.ui.common.blob.PosExcelEngine;
  5. import jxl.Cell;
  6. import jxl.CellType;
  7. import jxl.Sheet;
  8. import jxl.Workbook;
  9. import jxl.format.Alignment;
  10. import jxl.format.Border;
  11. import jxl.format.BorderLineStyle;
  12. import jxl.format.VerticalAlignment;
  13. import jxl.write.Label;
  14. import jxl.write.WritableCellFormat;
  15. import jxl.write.WritableFont;
  16. import jxl.write.WritableSheet;
  17. import jxl.write.WritableWorkbook;
  18. import jxl.write.WriteException;
  19. import jxl.write.biff.RowsExceededException;
  20. public class LGLzkPrint extends PosExcelEngine
  21. {
  22. private int TotalCols = 44;//原始38更改为44
  23. private int TheCols = 43;//原始37改为43
  24. private String pageCoilNo = null;
  25. protected void setData(Workbook rwb, WritableWorkbook wb) throws RowsExceededException, WriteException
  26. {
  27. Sheet rs = rwb.getSheet(0);//单元
  28. WritableSheet sheet = wb.getSheet(0); //可编辑单元,即副本
  29. List listHead = (List)dataList.get(0);
  30. List list = (List)dataList.get(1);
  31. List listChem = (List)dataList.get(2);//成分
  32. Label label = null;
  33. Cell cell = null;
  34. int FistRow = 3;//板坯号、重量、规格等填充开始行
  35. int secondRow = 13;//成分开始填充行
  36. ///车辆号、日期等
  37. int ZeroRow = 1;
  38. Map rowx = (Map)listHead.get(0);
  39. //流水号
  40. label = new Label(1 , ZeroRow , rowx.get("PRINT_ZH_NO")==null?"":rowx.get("PRINT_ZH_NO").toString() ,sheet.getCell(9 , ZeroRow).getCellFormat() );
  41. sheet.addCell(label);
  42. //流向
  43. label = new Label(9 , ZeroRow , rowx.get("CHAN_XIAN")==null?"":rowx.get("CHAN_XIAN").toString() ,sheet.getCell(9 , ZeroRow).getCellFormat() );
  44. sheet.addCell(label);
  45. //车辆号
  46. label = new Label(12 , ZeroRow , rowx.get("CAR_NO")==null?"":rowx.get("CAR_NO").toString() ,sheet.getCell(12 , ZeroRow).getCellFormat() );
  47. sheet.addCell(label);
  48. //发卡日期
  49. label = new Label(14 , ZeroRow , rowx.get("DATE_")==null?"":rowx.get("DATE_").toString() ,sheet.getCell(14 , ZeroRow).getCellFormat() );
  50. sheet.addCell(label);
  51. //打印人
  52. label = new Label(1 , 20 , rowx.get("REG_NM")==null?"":rowx.get("REG_NM").toString() ,sheet.getCell(1 , 20).getCellFormat() );
  53. sheet.addCell(label);
  54. //是否需要打印成分
  55. String needChem = rowx.get("NEED_CHEM").toString();
  56. if("N".equals(needChem ))
  57. {
  58. sheet.removeRow(secondRow-1);
  59. sheet.insertRow(secondRow-1);
  60. sheet.removeRow(secondRow-2);
  61. sheet.insertRow(secondRow-2);
  62. }
  63. ///板坯号、重量、规格等
  64. int rowTol = list.size();//查询结果行数
  65. for(int i =0 ; i< list.size(); i++)
  66. {
  67. Map row = (Map)list.get(i);
  68. for (int curRow = FistRow+i; curRow < FistRow+rowTol; curRow++)
  69. {
  70. for(int curCol = 0; curCol < 30; curCol++)
  71. {
  72. cell = sheet.getCell(curCol, FistRow-1);
  73. if(cell.getType() == CellType.EMPTY)continue;
  74. String conStr = cell.getContents().toString();//第3行
  75. //System.out.println("SLAB_NO========"+conStr);
  76. if(!"".equals(conStr) || conStr != null)
  77. {
  78. label = new Label(curCol , curRow ,row.get(conStr)==null?"":row.get(conStr).toString());
  79. sheet.addCell(label);
  80. }
  81. }
  82. }
  83. }//for end
  84. ///成分
  85. if("Y".equals(needChem))
  86. {
  87. rowTol = listChem.size();//查询结果行数
  88. for(int i =0 ; i< listChem.size(); i++)//成分
  89. {
  90. Map row = (Map)listChem.get(i);
  91. for (int curRow = secondRow+i; curRow < secondRow+rowTol; curRow++)
  92. {
  93. for(int curCol = 0; curCol < 30; curCol++)
  94. {
  95. cell = sheet.getCell(curCol, secondRow-1);
  96. if(cell.getType() == CellType.EMPTY)continue;
  97. String conStr = cell.getContents().toString().toUpperCase();//元素名,元素名转换为大写
  98. //System.out.println("CHEM========"+conStr);
  99. if(!"".equals(conStr) || conStr != null)
  100. {
  101. //System.out.println("-------------->"+row.get(conStr)==null?"":row.get(conStr).toString());
  102. label = new Label(curCol , curRow ,row.get(conStr)==null?"":row.get(conStr).toString());
  103. sheet.addCell(label);
  104. }
  105. }
  106. }
  107. }//for end
  108. }//if end
  109. }
  110. public void setData()
  111. {
  112. }
  113. }