Package jxl

Examples of jxl.Cell


      int column_count, String excel_file_name) {
    try {
      Workbook book = Workbook.getWorkbook(new File(excel_file_name));
      Sheet sheet = book.getSheet(0);
      al = new ArrayList();
      Cell cellKey;
      Cell cellValue;
      for (int i = 0; i < column_count; i++) {
        List columndatas = new ArrayList();
        cellKey = sheet.getCell(i, i);
        for (int k = 0; k < row_count; k++) {
          cellValue = sheet.getCell(i, k);
          // System.out.println("��:" + (k + 1) + "�е�" + (i + 1) +
          // "��ֵ��:"+ cellValue.getContents());
          columndatas.add(cellValue.getContents());
        }// end for k
        al.add(columndatas);// ��һ�����ݷ�װ���ܵ�list��
      }// end for i
      book.close();
      System.out.println("��ѯEXCEL�ļ�����!");
View Full Code Here


  public static List readExcelFileASheetByName(String excel_file_name) {
    try {
      Workbook book = Workbook.getWorkbook(new File(excel_file_name));
      Sheet sheet = book.getSheet(0);
      al = new ArrayList();
      Cell cellKey;
      Cell cellValue;
      for (int i = 0; i < column_count; i++) {
        List columndatas = new ArrayList();
        cellKey = sheet.getCell(i, i);
        for (int k = 0; k < row_count; k++) {
          cellValue = sheet.getCell(i, k);
          // System.out.println("��:" + (k + 1) + "�е�" + (i + 1) +
          // "��ֵ��:"+ cellValue.getContents());
          columndatas.add(cellValue.getContents());
        }// end for k
        al.add(columndatas);// ��һ�����ݷ�װ���ܵ�list��
      }// end for i
      book.close();
      System.out.println("��ѯEXCEL�ļ�����!");
View Full Code Here

    excelView.render(new HashMap<String, Object>(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    assertEquals("Test Sheet", wb.getSheet(0).getName());
    Sheet sheet = wb.getSheet("Test Sheet");
    Cell cell = sheet.getCell(2, 4);
    assertEquals("Test Value", cell.getContents());
  }
View Full Code Here

    excelView.setUrl("template");
    excelView.render(new HashMap<String, Object>(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template", cell.getContents());
  }
View Full Code Here

    excelView.setUrl("template");
    excelView.render(new HashMap<String, Object>(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template American English", cell.getContents());
  }
View Full Code Here

    excelView.setUrl("template");
    excelView.render(new HashMap<String, Object>(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template auf Deutsch", cell.getContents());
  }
View Full Code Here

   * 写入静态对象
   */
  private void fillStatics(WritableSheet wSheet) {
    List statics = getExcelTemplate().getStaticObject();
    for (int i = 0; i < statics.size(); i++) {
      Cell cell = (Cell) statics.get(i);
      Label label = new Label(cell.getColumn(), cell.getRow(), cell.getContents());
      label.setCellFormat(cell.getCellFormat());
      try {
        wSheet.addCell(label);
      } catch (Exception e) {
        log.error(G4Constants.Exception_Head + "写入静态对象发生错误!");
        e.printStackTrace();
View Full Code Here

   */
  private void fillParameters(WritableSheet wSheet) {
    List parameters = getExcelTemplate().getParameterObjct();
    Dto parameterDto = getExcelData().getParametersDto();
    for (int i = 0; i < parameters.size(); i++) {
      Cell cell = (Cell) parameters.get(i);
      String key = getKey(cell.getContents().trim());
      String type = getType(cell.getContents().trim());
      try {
        if (type.equalsIgnoreCase(G4Constants.ExcelTPL_DataType_Number)) {
          Number number = new Number(cell.getColumn(), cell.getRow(), parameterDto.getAsBigDecimal(key)
              .doubleValue());
          number.setCellFormat(cell.getCellFormat());
          wSheet.addCell(number);
        } else {
          Label label = new Label(cell.getColumn(), cell.getRow(), parameterDto.getAsString(key));
          label.setCellFormat(cell.getCellFormat());
          wSheet.addCell(label);
        }
      } catch (Exception e) {
        log.error(G4Constants.Exception_Head + "写入表格参数对象发生错误!");
        e.printStackTrace();
View Full Code Here

        dataDto.putAll(dto);
      } else {
        log.error(G4Constants.Exception_Head + "不支持的数据类型!");
      }
      for (int i = 0; i < fields.size(); i++) {
        Cell cell = (Cell) fields.get(i);
        String key = getKey(cell.getContents().trim());
        String type = getType(cell.getContents().trim());
        try {
          if (type.equalsIgnoreCase(G4Constants.ExcelTPL_DataType_Number)) {
            Number number = new Number(cell.getColumn(), cell.getRow() + j, dataDto.getAsBigDecimal(key)
                .doubleValue());
            number.setCellFormat(cell.getCellFormat());
            wSheet.addCell(number);
          } else {
            Label label = new Label(cell.getColumn(), cell.getRow() + j, dataDto.getAsString(key));
            label.setCellFormat(cell.getCellFormat());
            wSheet.addCell(label);
          }
        } catch (Exception e) {
          log.error(G4Constants.Exception_Head + "写入表格字段对象发生错误!");
          e.printStackTrace();
        }
      }
    }
    int row = 0;
    row += fieldList.size();
    if (G4Utils.isEmpty(fieldList)) {
      if (G4Utils.isNotEmpty(fields)) {
        Cell cell = (Cell) fields.get(0);
        row = cell.getRow();
        wSheet.removeRow(row+5);
        wSheet.removeRow(row+4);
        wSheet.removeRow(row+3);
        wSheet.removeRow(row+2);
        wSheet.removeRow(row+1);
        wSheet.removeRow(row);
      }
    }else {
      Cell cell = (Cell) fields.get(0);
      row += cell.getRow();
      fillVariables(wSheet, row);
    }
  }
View Full Code Here

   */
  private void fillVariables(WritableSheet wSheet, int row) {
    List variables = getExcelTemplate().getVariableObject();
    Dto parameterDto = getExcelData().getParametersDto();
    for (int i = 0; i < variables.size(); i++) {
      Cell cell = (Cell) variables.get(i);
      String key = getKey(cell.getContents().trim());
      String type = getType(cell.getContents().trim());
      try {
        if (type.equalsIgnoreCase(G4Constants.ExcelTPL_DataType_Number)) {
          Number number = new Number(cell.getColumn(), row, parameterDto.getAsBigDecimal(key).doubleValue());
          number.setCellFormat(cell.getCellFormat());
          wSheet.addCell(number);
        } else {
          String content = parameterDto.getAsString(key);
          if (G4Utils.isEmpty(content) && !key.equalsIgnoreCase("nbsp")) {
            content = key;
          }
          Label label = new Label(cell.getColumn(), row, content);
          label.setCellFormat(cell.getCellFormat());
          wSheet.addCell(label);
        }
      } catch (Exception e) {
        log.error(G4Constants.Exception_Head + "写入表格变量对象发生错误!");
        e.printStackTrace();
View Full Code Here

TOP

Related Classes of jxl.Cell

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.