Examples of createCell()


Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

    HSSFRow row = sheet.createRow(index); // 建立新行
    if (datas != null) {
      if (datas.getClass().isArray()) {
        Object[] values = (Object[]) datas;
        for (int i = 0; i < values.length; i++) {
          HSSFCell cell = row.createCell(i);
          if (values[i] instanceof Number) {
            cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
            cell.setCellValue(((Number) values[i]).doubleValue());
          } else if (values[i] instanceof java.sql.Date) {
            cell.setCellValue((Date) values[i]);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

            cell.setCellValue(new HSSFRichTextString((values[i] == null) ? "" : values[i]
                .toString()));
          }
        }
      } else {
        HSSFCell cell = row.createCell(0);
        // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        if (datas instanceof Number) {
          cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
        }
        cell.setCellValue(new HSSFRichTextString(datas.toString()));
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

    // Create a row and put some cells in it. Rows are 0 based.
    HSSFRow row = sheet.createRow(0);

    // Create a cell and put a date value in it. The first cell is not
    // styled as a date.
    HSSFCell cell = row.createCell(0);
    cell.setCellValue(new Date());

    // we style the second cell as a date (and time). It is important to
    // create a new cell style from the workbook
    // otherwise you can end up modifying the built in style and effecting
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

    // not only this cell but other cells.
    HSSFCellStyle cellStyle = wb.createCellStyle();
    DataFormat df = wb.createDataFormat();
    // cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
    cellStyle.setDataFormat(df.getFormat("YYYY-MM-DD HH:MM:SS"));
    cell = row.createCell(1);
    cell.setCellValue(new Date());
    cell.setCellStyle(cellStyle);
    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream("src/test/resources/workbook.xls");
    wb.write(fileOut);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

    String[] pShowKeys = Tokenizer2StringArray(propertyShowKeys, ",");
    // 创建�?行(标题)
    row = sheet.createRow(0); // 建立新行
    // 显示标题列名
    for (int i = 0; i < pShowKeys.length; i++) {
      cell = row.createCell(i); // 建立新cell
      // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
      cell.setCellValue(new HSSFRichTextString(pShowKeys[i]));
    }
    // 逐行取数
    int rowId = 1;// 数据行号(从2行开始填充数�?)
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

    for (Iterator<Object[]> iter = datas.iterator(); iter.hasNext(); rowId++) {
      row = sheet.createRow(rowId); // 建立新行
      Object[] objs = iter.next();
      // 生成每一�?
      for (int j = 0; j < objs.length; j++) {
        cell = row.createCell(j); // 建立新cell
        // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        cell.setCellValue(new HSSFRichTextString((objs[j] == null) ? "" : objs[j].toString()));
      }
    }
    return wb;
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

    /** *************** insert data to excel*************** */
    // 创建(标题)
    row = sheet.createRow(0); // 建立新行
    // 显示标题列名�?
    for (int i = 0; i < pShowKeys.length; i++) {
      cell = row.createCell(i); // 建立新cell
      // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
      cell.setCellValue(new HSSFRichTextString(pShowKeys[i]));
    }
    // 逐行取数�?
    int rowId = 1;// 数据行号(从�?2行开始填充数�?)
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

    for (Iterator<T> iter = list.iterator(); iter.hasNext(); rowId++) {
      row = sheet.createRow(rowId); // 建立新行
      T obj = iter.next();
      // 生成每一
      for (int i = 0; i < pKeys.length; i++) {
        cell = row.createCell(i); // 建立新cell
        cellVal = exporter.getPropertyValue(obj, pKeys[i]);
        // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        String cellValue = "";
        if (null != cellVal) {
          cellValue = cellVal.toString();
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

        for(int j = 0; j < gridCell.getColSpan(); j++)
        {
          HSSFCell spanCell = spanRow.getCell((colIndex + j));
          if (spanCell == null)
          {
            spanCell = spanRow.createCell((colIndex + j));
          }
          spanCell.setCellStyle(cellStyle);
        }
      }
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow.createCell()

        LinkedHashMap<String, Short> attributeNameMap = new LinkedHashMap<String, Short>();
        if ( this.exportDn )
        {
            short cellNum = ( short ) 0;
            attributeNameMap.put( "dn", new Short( cellNum ) ); //$NON-NLS-1$
            headerRow.createCell( cellNum ).setCellValue( "dn" ); //$NON-NLS-1$
        }

        // String[] exportAttributes =
        // this.searchParameter.getReturningAttributes();
        // exportAttributes = null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.