Examples of HSSFCell


Examples of com.dotcms.repackage.org.apache.poi.hssf.usermodel.HSSFCell

          HSSFRow row = (HSSFRow)rowIterator.next();

          Iterator cellIterator = row.cellIterator();

          while (cellIterator.hasNext()) {
            HSSFCell cell = (HSSFCell)cellIterator.next();

            String cellStringValue = null;

            if (cell.getCellType() == 4) {
              boolean booleanValue = cell.getBooleanCellValue();
              cellStringValue = Boolean.toString(booleanValue);
            }
            else if (cell.getCellType() == 0) {
              double doubleValue = cell.getNumericCellValue();
              cellStringValue = Double.toString(doubleValue);
            }
            else if (cell.getCellType() == 1) {
              cellStringValue = cell.getStringCellValue();
            }

            if (cellStringValue != null) {
              sb.append(cellStringValue);
              sb.append("\t");
View Full Code Here

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

      {
        HSSFSheet sheet = workbook.createSheet("Spring Excel View");
        sheet.setDefaultColumnWidth((short) 12);

        // Write a text at A1.
        HSSFCell cell = getCell(sheet, 0, 0);
        setText(cell, "Spring Excel View Via Strecks");

        // Write the current date at A2.
        HSSFCellStyle dateStyle = workbook.createCellStyle();
        dateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
        cell = getCell(sheet, 1, 0);
        cell.setCellValue(new Date());
        cell.setCellStyle(dateStyle);
      }
    };
    return new ModelAndView(view);
  }
View Full Code Here

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

                     // check if the rows are not null
                     if(row1 != null && row2 != null) {
                         Iterator it1 = row1.cellIterator();
                         Iterator it2 = row2.cellIterator();
                         while(it1.hasNext() && it2.hasNext()) {
                             HSSFCell cell1 = (HSSFCell) it1.next();
                             HSSFCell cell2 = (HSSFCell) it2.next();
                             if(cell1 != null && cell2 != null) {
                               HSSFCellStyle cell1Style = cell1.getCellStyle();
                               HSSFCellStyle cell2Style = cell2.getCellStyle();
                               if(cell1Style != null && cell2Style != null) {
                                 short cell1BorderBottom = cell1Style.getBorderBottom();
                                 short cell1Alignment = cell1Style.getAlignment();
                                 short cell1BorderLeft = cell1Style.getBorderLeft();
                                 short cell1BorderRight = cell1Style.getBorderRight();
                                 short cell1BorderTop = cell1Style.getBorderTop();
                                 short cell1BorderColor = cell1Style.getBottomBorderColor();
                                 short cell1DataFormat = cell1Style.getDataFormat();
                                 short cell1BackgroundColor = cell1Style.getFillBackgroundColor();
                                 short cell1FillForegroundColor = cell1Style.getFillForegroundColor();
                                 short cell1FillPattern = cell1Style.getFillPattern();
                                 short cell1LeftBorderColor = cell1Style.getLeftBorderColor();
                                 short cell1RightBorderColor = cell1Style.getRightBorderColor();
                                 short cell1VerticalAlignment = cell1Style.getVerticalAlignment();
                                 boolean cell1WrapText = cell1Style.getWrapText();
                                 short cell1Rotation = cell1Style.getRotation();
                                
                                 short cell2BorderBottom = cell2Style.getBorderBottom();
                                 short cell2Alignment = cell2Style.getAlignment();
                                 short cell2BorderLeft = cell2Style.getBorderLeft();
                                 short cell2BorderRight = cell2Style.getBorderRight();
                                 short cell2BorderTop = cell2Style.getBorderTop();
                                 short cell2BorderColor = cell2Style.getBottomBorderColor();
                                 short cell2DataFormat = cell2Style.getDataFormat();
                                 short cell2BackgroundColor = cell2Style.getFillBackgroundColor();
                                 short cell2FillForegroundColor = cell2Style.getFillForegroundColor();
                                 short cell2FillPattern = cell2Style.getFillPattern();
                                 short cell2LeftBorderColor = cell2Style.getLeftBorderColor();
                                 short cell2RightBorderColor = cell2Style.getRightBorderColor();
                                 short cell2VerticalAlignment = cell2Style.getVerticalAlignment();
                                 boolean cell2WrapText = cell2Style.getWrapText();
                                 short cell2Rotation = cell2Style.getRotation();
                                 if(cell1BorderBottom != cell2BorderBottom) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Bottom Border" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }
                                 if(cell1Alignment != cell2Alignment) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Cell Alignment" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }
                                 if(cell1BorderLeft != cell2BorderLeft) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Left Border" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }                                
                                 if(cell1BorderRight != cell2BorderRight) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Right Border" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }   
                                 if(cell1BorderTop != cell2BorderTop) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Top Border" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }                                 
//                                if(cell1BorderColor != cell2BorderColor) {
//                                     equal = false;
//                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Border Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
//                                     outputStream.write(dataToWrite.getBytes());
//                                 }   
                                 if(cell1DataFormat != cell2DataFormat) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Data Format" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }
                                 if(cell1BackgroundColor != cell2BackgroundColor) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Background Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }
                                 if(cell1FillForegroundColor != cell2FillForegroundColor) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Foreground Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }
                                 if(cell1FillPattern != cell2FillPattern) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Fill Pattern" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }  
/*                               if(cell1LeftBorderColor != cell2LeftBorderColor) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Left Border Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }
                                 if(cell2RightBorderColor != cell1RightBorderColor) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Right Border Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }*/
                                 if(cell1VerticalAlignment != cell2VerticalAlignment) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Vertical Alignment" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }
                                 if(cell1Rotation != cell2Rotation) {
                                     equal = false;
                                     String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Cell Rotation" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                                     outputStream.write(dataToWrite.getBytes());
                                 }                                 
                                 if(cell1WrapText != cell2WrapText) {
                                   equal = false;
                                   String dataToWrite = "Sheet # " + i + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Wrap Text" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ 
                                   outputStream.write(dataToWrite.getBytes());
                                 }
                               }                              
                               String cell1Value = cell1.toString();
                               String cell2Value = cell2.toString();
                               if(cell1Value != null && cell2Value != null) {
                                 if(cell1Value.equals(cell2Value)) {
                                   continue;
                                 } else {
                                   equal = false;
View Full Code Here

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

      Iterator it1 = row1.cellIterator();
      Iterator it2 = row2.cellIterator();
      while (it1.hasNext() && it2.hasNext())
      {
        HSSFCell cell1 = (HSSFCell) it1.next();
        HSSFCell cell2 = (HSSFCell) it2.next();
        if (cell1 == null || cell2 == null)
        {
          String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different data.. File 1 Cell has " + cell1 + "Whereas File2 has " + cell2 + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
          outputStream.write(dataToWrite.getBytes());
          return false;
        }

        HSSFCellStyle cell1Style = cell1.getCellStyle();
        HSSFCellStyle cell2Style = cell2.getCellStyle();
        if (cell1Style == null || cell2Style == null)
        {
          String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a no cell style.. File 1 Cell has " + cell1 + "Whereas File2 has " + cell2 + "\n";
          outputStream.write(dataToWrite.getBytes());
          return false;
        }
        else
        {
          short cell1BorderBottom = cell1Style.getBorderBottom();
          short cell1Alignment = cell1Style.getAlignment();
          short cell1BorderLeft = cell1Style.getBorderLeft();
          short cell1BorderRight = cell1Style.getBorderRight();
          short cell1BorderTop = cell1Style.getBorderTop();
          short cell1BorderColor = cell1Style.getBottomBorderColor();
          short cell1DataFormat = cell1Style.getDataFormat();
          short cell1BackgroundColor = cell1Style.getFillBackgroundColor();
          short cell1FillForegroundColor = cell1Style.getFillForegroundColor();
          short cell1FillPattern = cell1Style.getFillPattern();
          short cell1LeftBorderColor = cell1Style.getLeftBorderColor();
          short cell1RightBorderColor = cell1Style.getRightBorderColor();
          short cell1VerticalAlignment = cell1Style.getVerticalAlignment();
          boolean cell1WrapText = cell1Style.getWrapText();
          short cell1Rotation = cell1Style.getRotation();

          short cell2BorderBottom = cell2Style.getBorderBottom();
          short cell2Alignment = cell2Style.getAlignment();
          short cell2BorderLeft = cell2Style.getBorderLeft();
          short cell2BorderRight = cell2Style.getBorderRight();
          short cell2BorderTop = cell2Style.getBorderTop();
          short cell2BorderColor = cell2Style.getBottomBorderColor();
          short cell2DataFormat = cell2Style.getDataFormat();
          short cell2BackgroundColor = cell2Style.getFillBackgroundColor();
          short cell2FillForegroundColor = cell2Style.getFillForegroundColor();
          short cell2FillPattern = cell2Style.getFillPattern();
          short cell2LeftBorderColor = cell2Style.getLeftBorderColor();
          short cell2RightBorderColor = cell2Style.getRightBorderColor();
          short cell2VerticalAlignment = cell2Style.getVerticalAlignment();
          boolean cell2WrapText = cell2Style.getWrapText();
          short cell2Rotation = cell2Style.getRotation();
          if (cell1BorderBottom != cell2BorderBottom)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Bottom Border" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1Alignment != cell2Alignment)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Cell Alignment" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1BorderLeft != cell2BorderLeft)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Left Border" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1BorderRight != cell2BorderRight)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Right Border" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1BorderTop != cell2BorderTop)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Top Border" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1BorderColor != cell2BorderColor)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Border Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1DataFormat != cell2DataFormat)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Data Format" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1BackgroundColor != cell2BackgroundColor)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Background Color" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1FillForegroundColor != cell2FillForegroundColor)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Foreground Color" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1FillPattern != cell2FillPattern)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Fill Pattern" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1LeftBorderColor != cell2LeftBorderColor)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Left Border Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell2RightBorderColor != cell1RightBorderColor)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Right Border Color" + "\n";   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1VerticalAlignment != cell2VerticalAlignment)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Vertical Alignment" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1Rotation != cell2Rotation)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Cell Rotation" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
          if (cell1WrapText != cell2WrapText)
          {
            equal = false;
            String dataToWrite = "Sheet # " + sheetNumber + "Row # " + j + "Cell # " + cell1.getCellNum() + "has a different Wrap Text" + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
            outputStream.write(dataToWrite.getBytes());
          }
        }
        String cell1Value = cell1.toString();
        String cell2Value = cell2.toString();
        if (cell1Value != null && cell2Value != null)
        {
          if (cell1Value.equals(cell2Value) == false)
          {
            equal = false;
View Full Code Here

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

  }
 
  // ----------------------------------------------------------

  public void parseSheet(HSSFSheet oSheet, String sFileDescriptor) {
    HSSFCell oCel;
    HSSFRow oRow = oSheet.getRow(0);
    int iRow;
    char cDelim;
    String[] aFileDescriptor;
    int iFileDescLen;
   
    if (isVoid(sFileDescriptor)) {
      iRow = 1;
      sFileDescriptor = "";
      short iCel = (short) 0;
    oCel = oRow.getCell(iCel);
    while (oCel!=null) {
      if (isVoid(oCel.getStringCellValue())) break;
      sFileDescriptor += (sFileDescriptor.length()==0 ? "" : "\t") + oCel.getStringCellValue();
      oCel = oRow.getCell(++iCel);
    } // wend
    } else {
      iRow = 1;
      aFileDescriptor = Gadgets.split(sFileDescriptor, extractDelimiter(sFileDescriptor));
      iFileDescLen = aFileDescriptor.length;
      for (int c=0; c<iFileDescLen; c++) {
        oCel = oRow.getCell(c);
        if (null==oCel) {
          iRow = 0;
          break;
        } else if (!aFileDescriptor[c].equalsIgnoreCase(oCel.getStringCellValue())) {
          iRow = 0;
          break;         
        }
      } //next
    } // fi
View Full Code Here

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

   { HSSFRow cRow = cSheet.getRow(i);
     if (cRow == null) continue;      //*-- skip empty rows

     //*-- for every row, scan each cell from left to right
     for (short j = cRow.getFirstCellNum(); j <= cRow.getLastCellNum(); j++)
     { HSSFCell cCell = cRow.getCell(j);

     if (cCell == null) continue//*-- skip empty cells
     if (cCell.getCellType() == HSSFCell.CELL_TYPE_STRING)
      { String cellValue = cCell.getStringCellValue();
        if (cellValue != null) { sb.append(" "); sb.append(cellValue); }
      }  
     } //*-- end of inner for
   } //*-- end of outer for
   return (sb.toString());
View Full Code Here

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

    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]);
            cell.setCellStyle(getDateStyle());
          } else if (values[i] instanceof java.util.Date) {
            cell.setCellValue((Date) values[i]);
            cell.setCellStyle(getTimeStyle());
          } else if (values[i] instanceof Calendar) {
            cell.setCellValue((Calendar) values[i]);
            cell.setCellStyle(getTimeStyle());
          } else {
            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.HSSFCell

  protected String[] readLine(HSSFSheet sheet, int rowIndex) {
    HSSFRow row = sheet.getRow(rowIndex);
    logger.debug("values count:{}", row.getLastCellNum());
    List<String> attrList = CollectUtils.newArrayList();
    for (int i = 0; i < row.getLastCellNum(); i++) {
      HSSFCell cell = row.getCell(i);
      if (null != cell) {
        String attr = cell.getRichStringCellValue().getString();
        if (StringUtils.isEmpty(attr)) {
          break;
        } else {
          attrList.add(attr.trim());
        }
View Full Code Here

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

    // 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
    // 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);
    fileOut.close();
  }
View Full Code Here

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

  @Test(dependsOnMethods = { "testWrite" })
  public void testRead() throws Exception {
    File file = new File("src/test/resources/tmp.xls");
    FileInputStream in = new FileInputStream(file);
    HSSFWorkbook wb = new HSSFWorkbook(in);
    HSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0);
    // HSSFFont f = cell.getCellStyle().getFont(wb);
    // Assert.assertEquals(f.getBoldweight(), HSSFFont.BOLDWEIGHT_BOLD);
    Assert.assertEquals(cell.getCellStyle().getAlignment(), HSSFCellStyle.ALIGN_CENTER);
    in.close();
    file.delete();
  }
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.