Package jxl.write

Examples of jxl.write.WritableWorkbook


    xset.setLocale( Locale.ENGLISH );
    if (null == this.template) {
      return Workbook.createWorkbook( this.outputStream, xset );
    }
    else {
      final WritableWorkbook xwb = Workbook.createWorkbook( this.outputStream, this.template, xset );
      extractCellFormatsFrom( xwb );
      removeDataFrom( xwb );
      return xwb;
    }
  }
View Full Code Here


  {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
   
    try
    {
      WritableWorkbook wb = Workbook.createWorkbook(output);
      WritableSheet sheet = wb.createSheet("Foglio 1", 0);
     
      WritableFont wfBold = new WritableFont(WritableFont.COURIER, 8, WritableFont.BOLD);
      WritableCellFormat cfBold = new WritableCellFormat(wfBold);
     
      WritableFont wfNormal = new WritableFont(WritableFont.COURIER, 8, WritableFont.NO_BOLD);
      WritableCellFormat cfNormal = new WritableCellFormat(wfNormal);
      WritableCellFormat cfRight = new WritableCellFormat(wfNormal);
      cfRight.setAlignment(Alignment.RIGHT);
     
      WritableCellFormat cfRightBold = new WritableCellFormat(wfBold);
      cfRightBold.setAlignment(Alignment.RIGHT);
     
      DisplayFormat df = new NumberFormat("###,##0.00");
      WritableCellFormat cfNumber = new WritableCellFormat(wfNormal, df);
      cfNumber.setAlignment(Alignment.RIGHT);
     
      WritableCellFormat cfNumberBold = new WritableCellFormat(wfBold, df);
      cfNumberBold.setAlignment(Alignment.RIGHT);
     
      DisplayFormat df_ = new NumberFormat("########0");
      WritableCellFormat cfIntNumber = new WritableCellFormat(wfNormal, df_);
      cfIntNumber.setAlignment(Alignment.RIGHT);
     
      WritableCellFormat cfIntRightBold = new WritableCellFormat(wfBold, df_);
      cfIntRightBold.setAlignment(Alignment.RIGHT);
     
      WritableCellFormat cfIntRight = new WritableCellFormat(wfNormal, df_);
      cfIntRight.setAlignment(Alignment.RIGHT);
     
      Label cellValue;
      Number cellNumber;
      int col = 0;
      cellValue = new Label(col, 2, "", cfBold);
      sheet.setColumnView(col, 10);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Gruppo", cfBold);
      sheet.setColumnView(col, 10);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Mastro", cfBold);
      sheet.setColumnView(col, 10);
      sheet.addCell(cellValue);
      if(visible)
      {
        col++;
        cellValue = new Label(col, 2, "Conto", cfBold);
        sheet.setColumnView(col, 10);
        sheet.addCell(cellValue);
      }
      col++;
      cellValue = new Label(col, 2, "Descrizione", cfBold);
      sheet.setColumnView(col, 40);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Dare", cfBold);
      sheet.setColumnView(col, 20);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Avere", cfBold);
      sheet.setColumnView(col, 20);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Dare extr.", cfBold);
      sheet.setColumnView(col, 20);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Avere Extr.", cfBold);
      sheet.setColumnView(col, 20);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Saldo Dare", cfBold);
      sheet.setColumnView(col, 20);
      sheet.addCell(cellValue);
      col++;
      cellValue = new Label(col, 2, "Saldo Avere", cfBold);
      sheet.setColumnView(col, 20);
      sheet.addCell(cellValue);
     
      int riga = 2;
     
      for (RowBilancio bilancio : listaBilancio)
      {
        riga++;
        col = 0;
        if((StringUtility.checkNull(bilancio.getTipoAttivita())).equals(" ")) {
          cellValue = new Label(col, riga, "", cfNormal);
        } else {
          cellValue = new Label(col, riga, StringUtility.checkNull(bilancio.getTipoAttivita()), cfBold);
        }
        sheet.addCell(cellValue);
       
        col++;
        if((StringUtility.checkNull(bilancio.getGruppo())).equals(" ")) {
          cellValue = new Label(col, riga, "", cfIntNumber);
          sheet.addCell(cellValue);
        } else {
          cellNumber = new Number(col, riga, Integer.parseInt((StringUtility.checkNull(bilancio.getGruppo()))), cfIntRightBold);
          sheet.addCell(cellNumber);
        }
       
        col++;
        if((StringUtility.checkNull(bilancio.getMastro())).equals(" ")) {
          cellValue = new Label(col, riga, "", cfIntNumber);
          sheet.addCell(cellValue);
        } else {
          cellNumber = new Number(col, riga, Integer.parseInt((StringUtility.checkNull(bilancio.getMastro()))), cfIntRight);
          sheet.addCell(cellNumber);
        }
       
        if(visible)
        {
          col++;
          if((StringUtility.checkNull(bilancio.getConto())).equals(" ")) {
            cellValue = new Label(col, riga, "", cfIntNumber);
            sheet.addCell(cellValue);
          } else {
            cellNumber = new Number(col, riga, Integer.parseInt((StringUtility.checkNull(bilancio.getConto()))), cfIntRight);
            sheet.addCell(cellNumber);
          }
        }
       
        col++;
        if((StringUtility.checkNull(bilancio.getDescrizione())).equals(" ")) {
          cellValue = new Label(col, riga, "", cfNormal);
        } else {
         
          if(NumberUtils.checkNull(bilancio.getTipoRiga()) == 0 || NumberUtils.checkNull(bilancio.getTipoRiga()) == 1
            || NumberUtils.checkNull(bilancio.getTipoRiga()) == 2) {
            cellValue = new Label(col, riga, StringUtility.checkNull(bilancio.getDescrizione()), cfBold);
          } else {
            cellValue = new Label(col, riga, StringUtility.checkNull(bilancio.getDescrizione()), cfNormal);
          }
        }
        sheet.addCell(cellValue);
       
        col++;
       
        if(NumberUtils.checkNull(bilancio.getTipoRiga()) == 0 || NumberUtils.checkNull(bilancio.getTipoRiga()) == 1
          || NumberUtils.checkNull(bilancio.getTipoRiga()) == 2) {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getDare()), cfNumberBold);
        } else {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getDare()), cfNumber);
        }
        sheet.addCell(cellNumber);
       
        col++;
        if(NumberUtils.checkNull(bilancio.getTipoRiga()) == 0 || NumberUtils.checkNull(bilancio.getTipoRiga()) == 1
          || NumberUtils.checkNull(bilancio.getTipoRiga()) == 2) {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getAvere()), cfNumberBold);
        } else {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getAvere()), cfNumber);
        }
        sheet.addCell(cellNumber);
       
        col++;
        if(NumberUtils.checkNull(bilancio.getTipoRiga()) == 0 || NumberUtils.checkNull(bilancio.getTipoRiga()) == 1
          || NumberUtils.checkNull(bilancio.getTipoRiga()) == 2) {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getDareExtr()), cfNumberBold);
        } else {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getDareExtr()), cfNumber);
        }
        sheet.addCell(cellNumber);
       
        col++;
        if(NumberUtils.checkNull(bilancio.getTipoRiga()) == 0 || NumberUtils.checkNull(bilancio.getTipoRiga()) == 1
          || NumberUtils.checkNull(bilancio.getTipoRiga()) == 2) {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getAvereExtr()), cfNumberBold);
        } else {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getAvereExtr()), cfNumber);
        }
        sheet.addCell(cellNumber);
       
        col++;
        if(NumberUtils.checkNull(bilancio.getTipoRiga()) == 0 || NumberUtils.checkNull(bilancio.getTipoRiga()) == 1
          || NumberUtils.checkNull(bilancio.getTipoRiga()) == 2) {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getDareSaldo()), cfNumberBold);
        } else {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getDareSaldo()), cfNumber);
        }
        sheet.addCell(cellNumber);
       
        col++;
        if(NumberUtils.checkNull(bilancio.getTipoRiga()) == 0 || NumberUtils.checkNull(bilancio.getTipoRiga()) == 1
          || NumberUtils.checkNull(bilancio.getTipoRiga()) == 2) {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getAvereSaldo()), cfNumberBold);
        } else {
          cellNumber = new Number(col, riga, NumberUtils.checkNull(bilancio.getAvereSaldo()), cfNumber);
        }
        sheet.addCell(cellNumber);
      }
     
      wb.write();
      wb.close();
     
    } catch (Exception e) {
      e.printStackTrace();
    }
    return output;
View Full Code Here

  }

  public static void createXLS() {
    try {
      // ���ļ�
      WritableWorkbook book = Workbook.createWorkbook(new File(
          "students.xls"));

      // ������Ϊ"��һҳ"�Ĺ���������0��ʾ���ǵ�һҳ
      WritableSheet sheet = book.createSheet("��һҳ", 0);

      Label labelA = new Label(0, 0, "ѧ�����");
      Label labelB = new Label(1, 0, "ѧ������");
      Label labelC = new Label(2, 0, "ѧ������");
      Label labelD = new Label(3, 0, "ѧ���Ա�");
      Label labelE = new Label(4, 0, "ѧ������");
      Label labelF = new Label(5, 0, "ѧ���༶");

      // ������õĵ�Ԫ����ӵ���������
      sheet.addCell(labelA);
      sheet.addCell(labelB);
      sheet.addCell(labelC);
      sheet.addCell(labelD);
      sheet.addCell(labelE);
      sheet.addCell(labelF);

      /*
       * ����һ���������ֵĵ�Ԫ�� ����ʹ��Number��������·�����������﷨����
       */
      Label labelA1 = new Label(0, 1, "svk");
      Label labelB1 = new Label(1, 1, "����");
      Label labelC1 = new Label(2, 1, "S");
      Label labelD1 = new Label(3, 1, "A");
      Label labelE1 = new Label(4, 1, "E");
      Label labelF1 = new Label(5, 1, "��Q");

      sheet.addCell(labelA1);
      sheet.addCell(labelB1);
      sheet.addCell(labelC1);
      sheet.addCell(labelD1);
      sheet.addCell(labelE1);
      sheet.addCell(labelF1);

      // д�����ݲ��ر��ļ�
      book.write();
      book.close();
      System.out.println("�����ļ��ɹ�!");

    } catch (Exception e) {
      System.out.println(e);
    }
View Full Code Here

   *            excel_file_name
   */
  public static void writeExcelFile(List al, String excel_file_name) {
    try {
      // ���ļ�
      WritableWorkbook book = Workbook.createWorkbook(new File(
          excel_file_name));
      WritableSheet sheet = book.createSheet("��һҳ", 0);

      for (int i = 0; i < al.size(); i++) {
        List ao = (List) al.get(i);
        for (int k = 0; k < ao.size(); k++) {
          Label datas = new Label(i+1, k, ao.get(k).toString());
          sheet.addCell(datas);
        }
      }
      // д�����ݲ��ر��ļ�
      book.write();
      book.close();
      System.out.println("�����ļ��ɹ�!");
    } catch (Exception e) {
      System.out.println(e);
    }
  }
View Full Code Here

   *            al
   */
  public static void writeExcelFile(List al) {
    try {
      // ���ļ�
      WritableWorkbook book = Workbook.createWorkbook(new File(
          excel_file_name));
      WritableSheet sheet = book.createSheet("��һҳ", 0);

      for (int i = 0; i < al.size(); i++) {
        List ao = (List) al.get(i);
        for (int k = 0; k < ao.size(); k++) {
          Label datas = new Label(i+1, k, ao.get(k).toString());
          sheet.addCell(datas);
        }
      }
      // д�����ݲ��ر��ļ�
      book.write();
      book.close();
      System.out.println("�����ļ��ɹ�!");
    } catch (Exception e) {
      System.out.println(e);
    }
  }
View Full Code Here

    // Set the content type and get the output stream.
    response.setContentType(getContentType());
    OutputStream out = response.getOutputStream();

    WritableWorkbook workbook;
    if (this.url != null) {
      Workbook template = getTemplateSource(this.url, request);
      workbook = Workbook.createWorkbook(out, template);
    }
    else {
      logger.debug("Creating Excel Workbook from scratch");
      workbook = Workbook.createWorkbook(out);
    }

    buildExcelDocument(model, workbook, request, response);

    // Should we set the content length here?
    // response.setContentLength(workbook.getBytes().length);

    workbook.write();
    out.flush();
    workbook.close();
  }
View Full Code Here

   
    // Set the content type and get the output stream.
    response.setContentType(getContentType());
    OutputStream out = response.getOutputStream();

    WritableWorkbook workbook;
    if (this.url != null) {
      Workbook template = getTemplateSource(this.url, request);
      workbook = Workbook.createWorkbook(out, template);
    }
    else {
      logger.debug("Creating Excel Workbook from scratch");
      workbook = Workbook.createWorkbook(out);
    }

    buildExcelDocument(model, workbook, request, response);

    // Should we set the content length here?
    // response.setContentLength(workbook.getBytes().length);

    workbook.write();
    out.flush();
    workbook.close();
  }
View Full Code Here

    WritableSheet wSheet = null;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
          InputStream is = request.getSession().getServletContext().getResourceAsStream(getExcelTemplate().getTemplatePath());
      Workbook wb = Workbook.getWorkbook(is);
      WritableWorkbook wwb = Workbook.createWorkbook(bos, wb);
      wSheet = wwb.getSheet(0);
      fillStatics(wSheet);
      fillParameters(wSheet);
      fillFields(wSheet);
      if (G4Utils.isNotEmpty(getExcelData().getFieldsList())) {
        // fillFields(wSheet);
      }
      wwb.write();
      wwb.close();
      wb.close();
    } catch (Exception e) {
      log.error(G4Constants.Exception_Head + "基于模板生成可写工作表出错了!");
      e.printStackTrace();
    }
View Full Code Here

      return null;
    }
    //取得排序的Rule明細
    List<DivRlDtl> rlDtls = ruleTbMntService.findRlDtlsByRlNoAndSort(rlItm.getDivRlNo());//rlItm.getDivRlDtls();
    List<DivCtItm> ctItms = null;
    WritableWorkbook workbook = null;
    File relFile = null;
    try{
      File fileDir = new File("../Temp");
      FileUtils.forceMkdir(fileDir);
      // 使用Char(3.6) 取得承辦分行資料。
      List<Map<String, Object>> lnf312Data = new ArrayList<Map<String,Object>>();
      String BRNO = "", BRNM = "";
      StringBuffer BRNoNm=new StringBuffer();
      if(!CollectionUtils.isEmpty(lnf312Data)){
        for(Map<String, Object> map : lnf312Data){
          BRNO = MapUtils.getString(map, "BRNO")+" ";
          BRNM = MapUtils.getString(map, "BRNM")+" ";
          BRNoNm.append(BRNO).append(BRNM);
        }
      }

      relFile = new File(fileDir + File.separator + CapDate.getCurrentDate("yyyyMMdd") + "_ruleExport.xls");
      relFile.createNewFile();
      // 2. 產生 workbook
      workbook = Workbook.createWorkbook(relFile);
      WritableSheet sheet1 = workbook.createSheet("Tables", 0);
      WritableFont myFont = new WritableFont(WritableFont.createFont("Arial"), 12);
      WritableFont boldWhiteFnt =
          new WritableFont(WritableFont.createFont("Arial"), 12, WritableFont.BOLD);
      boldWhiteFnt.setColour(Colour.WHITE);
      WritableFont blackFnt =
          new WritableFont(WritableFont.createFont("Arial"), 12, WritableFont.NO_BOLD);
      blackFnt.setColour(Colour.BLACK);
      // 第1行先放空白資料,並設定欄寬--->還沒設定
      //DecisionTable起始先告區(黑底白字)
      WritableCellFormat headCellFmt = new WritableCellFormat();
      //自動換行
      headCellFmt.setWrap(false);
      //水平靠左
      headCellFmt.setAlignment(Alignment.LEFT);
      //垂直置中
      headCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
      //設字形
      headCellFmt.setFont(boldWhiteFnt);
      //設欄位框(細)線
//      headCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
      //設定顏色
      headCellFmt.setBackground(Colour.GRAY_80);
     
      //DecisionTable內容橘底黑字
      WritableCellFormat setCellFmt = new WritableCellFormat();
      //自動換行
      setCellFmt.setWrap(true);
      //水平靠左
      setCellFmt.setAlignment(Alignment.LEFT);
      //垂直置中
      setCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
      //設字形
      setCellFmt.setFont(myFont);
      //設欄位框(細)線
      setCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
      //設定顏色(粉橘色)
      setCellFmt.setBackground(Colour.TAN);
     
      //DecisionTable內容白底黑字
      WritableCellFormat bodyCellFmt = new WritableCellFormat();
      //自動換行
      bodyCellFmt.setWrap(false);
      //水平靠左
      bodyCellFmt.setAlignment(Alignment.LEFT);
      //垂直置中
      bodyCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
      //設字形
      bodyCellFmt.setFont(myFont);
      //設欄位框(細)線
      bodyCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
      //設定顏色
//      bodyCellFmt.setBackground(Colour.BLACK);
     

      //DecisionTable內容藍底黑字
      WritableCellFormat blueCellFmt = new WritableCellFormat();
      //自動換行
      blueCellFmt.setWrap(false);
      //水平靠左
      blueCellFmt.setAlignment(Alignment.LEFT);
      //垂直置中
      blueCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
      //設字形
      blueCellFmt.setFont(myFont);
      //設欄位框(細)線
      blueCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
      blueCellFmt.setBackground(Colour.LIGHT_TURQUOISE);

      //DecisionTable內容黃底黑字
      WritableCellFormat yellowCellFmt = new WritableCellFormat();
      //自動換行
      yellowCellFmt.setWrap(false);
      //水平靠左
      yellowCellFmt.setAlignment(Alignment.LEFT);
      //垂直置中
      yellowCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
      //設字形
      yellowCellFmt.setFont(myFont);
      //設欄位框(細)線
      yellowCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
      yellowCellFmt.setBackground(Colour.YELLOW);

      //DecisionTable內容綠底黑字
      WritableCellFormat greenCellFmt = new WritableCellFormat();
      //自動換行
      greenCellFmt.setWrap(false);
      //水平靠左
      greenCellFmt.setAlignment(Alignment.LEFT);
      //垂直置中
      greenCellFmt.setVerticalAlignment(VerticalAlignment.TOP);
      //設字形
      greenCellFmt.setFont(myFont);
      //設欄位框(細)線
      greenCellFmt.setBorder(Border.ALL,BorderLineStyle.THIN, Colour.BLACK);
      greenCellFmt.setBackground(Colour.LIGHT_GREEN);
     
      //設列高
//      int row = 0;
//      sheet1.setRowView(row,450);
      //將第row行的欄寬設為100
//      sheet1.setColumnView(row, 100);
      // 合併儲存格(x,y, x1,y2)
//      sheet1.mergeCells(0, row, 11, row);
//      sheet1.addCell(new Label(0, 0, "", bodyCellFmt));
//      sheet1.setColumnView(0, 26);
     
      for(int i = 0; i < 65535; i++){
        sheet1.setRowView(i+1,450);
        sheet1.setColumnView(i, 23);
      }
      sheet1.setRowView(12,900);
     
      //DecisionTable開頭宣告-參數
      NumberFormat nf = new DecimalFormat("#.00");
      sheet1.addCell(new Label(1, 2, "RuleSet", headCellFmt));
      sheet1.addCell(new Label(1, 3, "Import", headCellFmt));
      sheet1.addCell(new Label(1, 4, "EscapeQuotes", headCellFmt));
      sheet1.addCell(new Label(1, 5, "Variables", headCellFmt));
      sheet1.addCell(new Label(1, 6, "Functions", headCellFmt));
      sheet1.addCell(new Label(1, 7, "Notes", headCellFmt));
      sheet1.addCell(new Label(1, 9, "RuleTable "+ rlItm.getDivRlNm(), headCellFmt));

      //DecisionTable開頭宣告-值
      sheet1.addCell(new Label(2, 2, DroolsConstants.PACKAGE_NAME, headCellFmt));
      sheet1.addCell(new Label(2, 3, DroolsConstants.IMPORT_CLASS, headCellFmt));
      sheet1.addCell(new Label(2, 4, "false", headCellFmt));
      sheet1.addCell(new Label(2, 5, DroolsConstants.VARIABLES_NAME, headCellFmt));
      //設定均量化參數
      sheet1.addCell(new Label(2, 6, "", headCellFmt));
      sheet1.addCell(new Label(2, 7, "This is decision table for "+rlItm.getDivRlNm()
          , headCellFmt));
      sheet1.addCell(new Label(2, 9, "", headCellFmt));
      //excel合併儲存格(著色)
      for(int i = 0;i <6; i++){       
        sheet1.mergeCells(2, 2+i, 7, 2+i);
      }
      //合併儲存格
      sheet1.mergeCells(2, 9, 7, 9);
      /*以下為條件判斷,分案設定內容*/
      //這一行要先決定開多少個condition和action
      //查出所有condition detail
      int conditionMaxCount = 0;
      //記錄有多少database table & column會用來做判斷
      List<String> tableNms = new ArrayList<String>();
      Map<String, DivCtDtl> colNms = new LinkedHashMap<String, DivCtDtl>();
      //排序的條件明細把它放到一個總集合,之後要填條件內容值($param)
      List<DivCtItm> ctItmList = new ArrayList<DivCtItm>();
      for(DivRlDtl rlDtl : rlDtls){
        DivCtItm ctItm = conditionMntService.findByDivCtItmNo(rlDtl.getDivCtNo());
        if(ctItm.getDivCtDtls()!=null && ctItm.getDivCtDtls().size()>conditionMaxCount){
          conditionMaxCount = ctItm.getDivCtDtls().size();
        }
        //排序的條件明細
        List<DivCtDtl> ctDtls = conditionMntService.findCtDtlsByCtNoAndSort(ctItm.getDivCtNo());
        //算出有幾種因子(因子和條件為1to1)
        for(DivCtDtl ctDtl : ctDtls){
          if(ctDtl.getDivFtDtl()!=null && ctDtl.getDivFtDtl().getDivFtItm()!=null){
            DivFtItm ftItm = ctDtl.getDivFtDtl().getDivFtItm();
            String tableNm = ftItm.getTableNm();
            String colNm = ftItm.getColumnNm();
            //每一種因子只會出現在CONDITION欄位一次
            if(!tableNms.contains(tableNm)){
              tableNms.add(tableNm);
            }
            if(!colNms.containsKey(colNm)){
              colNms.put(colNm, ctDtl);
            }
          }
        }
        ctItmList.add(ctItm);
      }//算完rule detail的內容

      //開始寫RuleTable第二行(抬頭)
      int i = 0, j = 0 ;
      Map<String, Integer> colSortNo = new HashMap<String, Integer>();
      for(String key : colNms.keySet()){
        DivCtDtl ctDtl = colNms.get(key);
        //CONDITOIN宣告欄位
        sheet1.addCell(new Label(1+j, 10, DroolsConstants.CONDITION_COL, setCellFmt));
        //資料型別宣告
        sheet1.addCell(new Label(1+j, 11, "beanClz:"+tableNms.get(0), setCellFmt));
        //這一行要擺 物件.屬性 + "比較運算元" + param/$1,$2
        String operand = "";
        if(ctDtl.getDivFtDtl()!=null){
          DivFtDtl ftDtl = ctDtl.getDivFtDtl();
          if(!CapString.isEmpty(ftDtl.getRange1()) && !CapString.isEmpty(ftDtl.getRange2())){
            operand = "$1<"+key+"&&"+key+"<=$2";
          }else{
            operand = key+"==$param";
          }
        }
        sheet1.addCell(new Label(1+j, 12, operand, setCellFmt));
        sheet1.addCell(new Label(1+j, 13, key, blueCellFmt));
        colSortNo.put(key, 1+j);
        i++;
        j++;
      }
      //Bean 宣告合併欄位
      sheet1.mergeCells(1, 11, j, 11);
     
      //宣告完CONDITION欄位,在宣告ACTIVITION-GROUP&NO-LOOP&PRIORITY
      int actGpColNo = 1+j;
      sheet1.addCell(new Label(actGpColNo, 10, DroolsConstants.ACTIVATION_GROUP, setCellFmt));
      sheet1.addCell(new Label(actGpColNo, 11, "", setCellFmt));
      sheet1.addCell(new Label(actGpColNo, 12, "", setCellFmt));
      sheet1.addCell(new Label(actGpColNo, 13, "activation group", blueCellFmt));
      int noLpColNo = actGpColNo+1;
      sheet1.addCell(new Label(noLpColNo, 10, DroolsConstants.NO_LOOP, setCellFmt));
      sheet1.addCell(new Label(noLpColNo, 11, "", setCellFmt));
      sheet1.addCell(new Label(noLpColNo, 12, "", setCellFmt));
      sheet1.addCell(new Label(noLpColNo, 13, "no loop", blueCellFmt));
      int priColNo = noLpColNo+1;
      sheet1.addCell(new Label(priColNo, 10, DroolsConstants.PRIORITY, setCellFmt));
      sheet1.addCell(new Label(priColNo, 11, "", setCellFmt));
      sheet1.addCell(new Label(priColNo, 12, "", setCellFmt));
      sheet1.addCell(new Label(priColNo, 13, "priority", blueCellFmt));
     
      //最後宣告ACTION
      int actColNo1 = priColNo+1;
      sheet1.addCell(new Label(actColNo1, 10, DroolsConstants.ACTION_COL, setCellFmt));
      sheet1.addCell(new Label(actColNo1, 11, "", setCellFmt));
      sheet1.addCell(new Label(actColNo1, 12, "beanClz.setGrpUppId(\"$param\");", setCellFmt));
      sheet1.addCell(new Label(actColNo1, 13, "", yellowCellFmt));

      int actColNo2 = actColNo1+1;
      sheet1.addCell(new Label(actColNo2, 10, DroolsConstants.ACTION_COL, setCellFmt));
      sheet1.addCell(new Label(actColNo2, 11, "", setCellFmt));
      sheet1.addCell(new Label(actColNo2, 12, "beanClz.setDocStatus(\"$param\");", setCellFmt));
      sheet1.addCell(new Label(actColNo2, 13, "", yellowCellFmt));
     
      int actColNo3 = actColNo2+1;
      sheet1.addCell(new Label(actColNo3, 10, DroolsConstants.ACTION_COL, setCellFmt));
      sheet1.addCell(new Label(actColNo3, 11, "", setCellFmt));
      sheet1.addCell(new Label(actColNo3, 12, "System.out.println(\"$param\"+ \" CASEINFO IS "
          + "\" +beanClz.getCasNo()+\" ** 分組結果 = "
          + "\" +beanClz.getGrpUppId() );", setCellFmt));
      sheet1.addCell(new Label(actColNo3, 13, "", yellowCellFmt));
      sheet1.addCell(new Label(0, 13, "Base rules", greenCellFmt));

      /*
       * 將總明細資料一筆一筆拆開來,將condition-->factor的值域填到Excel
       */
      if(!ctItmList.isEmpty()){
        int rowNo = 14, count = 0;
        for(DivCtItm ctItm : ctItmList){
          if(ctItm.getDivCtDtls()!=null){
            //CtItm list對應到自己的CtDtl,所以一筆CtItm就是一行Rule Row
            for(DivCtDtl ctDtl : ctItm.getDivCtDtls()){
              ctItm = ctDtl.getDivCtItm();
              //設定Action動作
              sheet1.addCell(new Label(actColNo1, rowNo, ctItm.getDivCtAction(), bodyCellFmt));
              sheet1.addCell(new Label(actColNo2, rowNo, ctItm.getDivCtSetting(), bodyCellFmt));
              sheet1.addCell(new Label(actColNo3, rowNo, "Test Condition::"+ctItm.getDivCtNm(), bodyCellFmt));

              DivFtDtl ftDtl = ctDtl.getDivFtDtl();
              String colNm = ftDtl.getDivFtItm().getColumnNm();
              //取得要放到第幾個cell
              Integer colNo = colSortNo.get(colNm);
              String rangeVal = "";
              if(!CapString.isEmpty(ftDtl.getRange1())){
                rangeVal = ftDtl.getRange1();
              }
              if(!CapString.isEmpty(ftDtl.getRange2())){
                rangeVal += ","+ftDtl.getRange2();
              }
              //設定行row名稱(rule name)
              sheet1.addCell(new Label(0, rowNo, ctDtl.getDivCtItm().getDivCtNm(), bodyCellFmt));
              //放入值域
              sheet1.addCell(new Label(colNo, rowNo, rangeVal, bodyCellFmt));
            }
            sheet1.addCell(new Label(actGpColNo, rowNo, "group", bodyCellFmt));
            sheet1.addCell(new Label(noLpColNo, rowNo, "true", bodyCellFmt));
            sheet1.addCell(new Label(priColNo, rowNo, String.valueOf(ctItmList.size()-count), bodyCellFmt));
            rowNo++;
            count++;
          }
        }
      }
     
      /*內容END*/

      workbook.write();
      workbook.close();
     
    }catch(Exception e){
      e.printStackTrace();
   
    return relFile;
View Full Code Here

        File file = new File(inputFile);
        WorkbookSettings wbSettings = new WorkbookSettings();

        wbSettings.setLocale(new Locale("en", "EN"));

        WritableWorkbook workbook = Workbook.createWorkbook(file, wbSettings);
        workbook.createSheet("PerformanceBenchmark", 0);
        WritableSheet excelSheet = workbook.getSheet(0);
        createLabel(excelSheet, testSummatyField);
        createContent(excelSheet, map);

        workbook.write();
        workbook.close();
    }
View Full Code Here

TOP

Related Classes of jxl.write.WritableWorkbook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.