Examples of HSSFRow


Examples of org.apache.poi.hssf.usermodel.HSSFRow

   * @throws Exception
   */
  public HSSFWorkbook toExcel(HSSFWorkbook wb, String sheetName, Collection<Object[]> datas,
      String propertyShowKeys) throws Exception {
    HSSFSheet sheet = wb.createSheet(sheetName);
    HSSFRow row = null;
    HSSFCell cell = null;

    /** **************** 取得传入的list列名称和显示名称 ********** */
    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行开始填充数�?)
    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

   */
  public <T extends Object> HSSFWorkbook object2Excel(HSSFWorkbook wb, String sheetName,
      Collection<T> list, String propertyKeys, String propertyShowKeys, PropertyExtractor exporter)
      throws Exception {
    HSSFSheet sheet = wb.createSheet(sheetName);
    HSSFRow row = null;
    HSSFCell cell = null;
    Object cellVal = null;

    /** **************** 取得传入的list列名称和显示名称 ********** */
    String[] pKeys = Tokenizer2StringArray(propertyKeys, ",");
    String[] pShowKeys = Tokenizer2StringArray(propertyShowKeys, ",");
    /** *************** 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行开始填充数�?)
    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

      sheet.addMergedRegion(new CellRangeAddress(rowIndex, (rowIndex + rowSpan - 1),
          colIndex, (colIndex + gridCell.getColSpan() - 1)));

      for(int i = 0; i < rowSpan; i++)
      {
        HSSFRow spanRow = sheet.getRow(rowIndex + i);
        if (spanRow == null)
        {
          spanRow = sheet.createRow(rowIndex + i);
        }
        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

      for (int sheetNumber = 0; sheetNumber < workbook.getNumberOfSheets(); sheetNumber++) {
        HSSFSheet sheet = workbook.getSheetAt(sheetNumber);
        if (sheet != null) {
          for (int rowNumber = sheet.getFirstRowNum(); rowNumber <= sheet.getLastRowNum(); rowNumber++) {
            HSSFRow row = sheet.getRow(rowNumber);
            if (row != null) {
              for (int cellNumber = row.getFirstCellNum(); cellNumber <= row.getLastCellNum(); cellNumber++) {
                HSSFCell cell = row.getCell(cellNumber);
                if (cell != null) {
                  // if (cell.getCellStyle().equals(HSSFCell.CELL_TYPE_NUMERIC))
                  if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                    content.append(cell.getStringCellValue()).append(' ');
                  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

        {
           
            Ref3DPtg ptg3D = (Ref3DPtg)ptg;
           
            HSSFSheet sheet = _workbook.getSheetAt(ptg3D.getExternSheetIndex() + 1 );     
            HSSFRow row     = sheet.getRow(ptg3D.getRow())
            HSSFCell cell   = row.getCell(ptg3D.getColumn());
           
            _currentSheetListener.newCell( formulaRec.getRow( ),
                    formulaRec.getColumn( ),
                                       "" + cell.getStringCellValue() );
                   
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet( "Export" ); //$NON-NLS-1$

        // header
        HSSFRow headerRow = sheet.createRow( 0 );
        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;
        // for (int i = 0; exportAttributes != null && i <
        // exportAttributes.length; i++) {
        // short cellNum = (short)attributeNameMap.size();
        // attributeNameMap.put(exportAttributes[i], new Short(cellNum));
        // headerRow.createCell(cellNum).setCellValue(exportAttributes[i]);
        // }

        // max export
        if ( searchParameter.getCountLimit() < 1 || searchParameter.getCountLimit() > MAX_COUNT_LIMIT )
        {
            searchParameter.setCountLimit( MAX_COUNT_LIMIT );
        }

        // export
        try
        {
            int count = 0;
            exportToXls( browserConnection, searchParameter, sheet, headerRow, count, monitor, attributeNameMap,
                valueDelimiter, binaryEncoding, this.exportDn );
        }
        catch ( Exception e )
        {
            monitor.reportError( e );
        }

        // column width
        for ( int i = 0; i <= sheet.getLastRowNum(); i++ )
        {
            HSSFRow row = sheet.getRow( i );
            for ( short j = 0; row != null && j <= row.getLastCellNum(); j++ )
            {
                HSSFCell cell = row.getCell( j );
                if ( cell != null && cell.getCellType() == HSSFCell.CELL_TYPE_STRING )
                {
                    String value = cell.getStringCellValue();

                    if ( ( short ) ( value.length() * 256 * 1.1 ) > sheet.getColumnWidth( j ) )
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

        // group multi-valued attributes
        Map<String, String> attributeMap = ExportCsvJob.getAttributeMap( null, record, valueDelimiter, "UTF-16",
            binaryEncoding );

        // output attributes
        HSSFRow row = sheet.createRow( sheet.getLastRowNum() + 1 );
        if ( exportDn )
        {
            HSSFCell cell = row.createCell( ( short ) 0 );
            cell.setEncoding( HSSFCell.ENCODING_UTF_16 );
            cell.setCellValue( record.getDnLine().getValueAsString() );
        }
        for ( String attributeName : attributeMap.keySet() )
        {
            String value = ( String ) attributeMap.get( attributeName );

            if ( !headerRowAttributeNameMap.containsKey( attributeName ) )
            {
                short cellNum = ( short ) headerRowAttributeNameMap.size();
                headerRowAttributeNameMap.put( attributeName, new Short( cellNum ) );
                HSSFCell cell = headerRow.createCell( cellNum );
                cell.setEncoding( HSSFCell.ENCODING_UTF_16 );
                cell.setCellValue( attributeName );
            }

            if ( headerRowAttributeNameMap.containsKey( attributeName ) )
            {
                short cellNum = ( ( Short ) headerRowAttributeNameMap.get( attributeName ) ).shortValue();
                HSSFCell cell = row.createCell( cellNum );
                cell.setEncoding( HSSFCell.ENCODING_UTF_16 );
                cell.setCellValue( value );
            }
        }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

   * the result of a function gets translated to {@link BlankEval}.
   */
  public void testMissingArg() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");
    HSSFRow row = sheet.createRow(0);
    HSSFCell cell = row.createCell(0);
    cell.setCellFormula("1+IF(1,,)");
    HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
    CellValue cv;
    try {
      cv = fe.evaluate(cell);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

     * @param rownum 対象の行番号
     * @param col 対象のカラム番号
     * @return 対応するセルの内容
     */
    private HSSFCell getCell(HSSFSheet sheet, int rownum, int col) {
        HSSFRow row = sheet.getRow(rownum);
        if (isEmpty(row)) {
            String fmt = "Excelファイルが異常です(空行), file = %s, sheet = %s, row = %d";
            String msg = String.format(fmt, filename, sheet.getSheetName(), rownum);
            throw new InvalidExcelBookException(msg);
        }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFRow

        List<ColumnInfo> list = new ArrayList<ColumnInfo>();

        int rownum = ConditionSheetItem.NO.getRow();
        for (;;) {
            rownum++;
            HSSFRow row = testConditionSheet.getRow(rownum);
            if (isEmpty(row)) {
                break;
            }

            // カラム名
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.