Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Cell


    int cols = style.getEndCol() - style.getStartCol();
    for(int i= position[0]; i<= position[0] + rows; i++){
      Row row = styleSheet.getRow(i);
      if(row == null) return;
      for(int j= position[1]; j<= position[1] + cols; j++){
        Cell cell = row.getCell(j);
        if(cell == null) return;
        styleMap.put(ExcelUtil.getCellIndex(i, j), cell.getCellStyle());
        if(logger.isDebugEnabled()){
          logger.debug("Condition Style [{}]", ExcelUtil.getCellIndex(i, j));
        }
      }
    }   
View Full Code Here


      if(row == null) row = sheet.createRow(rowIndex);
      for(int c = startColIndex; c <= endColIndex; c ++){
        String cIdx = ExcelUtil.offsetCellIndex(cellIndex, rowIndex-startRowIndex, c - startColIndex);
        CellStyle style = styleMap.get(cIdx);
        if(style == null) continue;
        Cell cell = row.getCell(c);
        if(cell == null) cell = row.createCell(c)
        cell.setCellStyle(style);
      }
    }
  }
View Full Code Here

 
  private void setCellStyle(Sheet sheet, int rowIndex, int cellIndex, CellStyle style){
    if(style == null) return;
    Row row = sheet.getRow(rowIndex);
    if(row == null) row = sheet.createRow(rowIndex);
    Cell cell = row.getCell(cellIndex);
    if(cell == null) cell = row.createCell(cellIndex);     
    if(cell.getCellStyle() == null || (cell.getCellType() != Cell.CELL_TYPE_NUMERIC)
        || (!DateUtil.isCellDateFormatted(cell))
        || DateUtil.isADateFormat(style.getDataFormat(), style.getDataFormatString()))
      cell.setCellStyle(style);
    else{     
      CellStyle cstyle = sheet.getWorkbook().createCellStyle();
      cstyle.cloneStyleFrom(style);
      cstyle.setDataFormat(cell.getCellStyle().getDataFormat());
      cell.setCellStyle(cstyle);
    }
  }
View Full Code Here

 
  private void setCellValue(Sheet sheet, int rowIndex, int cellIndex, String dataName, OgnlStack stack){
    if(dataName.equals("#")) return;
    Row row = sheet.getRow(rowIndex);
    if(row == null) row = sheet.createRow(rowIndex);
    Cell cell = row.getCell(cellIndex);
    if(cell == null) cell = row.createCell(cellIndex);   
    if(dataName.startsWith("=")){
      //formula
      cell.setCellFormula(dataName.substring(1));
    }else{
      //data
      try {
        Object value = stack.getValue(dataName);
        setCellValue(cell, value);
View Full Code Here

    for (int r = 0; r < data.getRowCount(); r += 1)
    {
      Row row = sheet.getRow(r);
      for (int c = 0; c < data.getColumnCount(); c += 1)
      {
        Cell cell = row.getCell(c);

        Object valueAt = data.getValueAt(r, c);
        if (valueAt == null)
        {
          if (cell != null)
          {
            // excel cells never return null
            Assert.assertEquals("", cell.getStringCellValue());
          }
        }
        else
        {
          Assert.assertEquals(valueAt, cell.getStringCellValue());
        }
      }

    }
View Full Code Here

            // An empty cell .. ignore
            continue;
          }

          // A empty cell with a defined background ..
          final Cell cell = getCellAt(col, row);
          final CellStyle style =
              getCellStyleProducer().createCellStyle(null, null, background);
          if (style != null)
          {
            cell.setCellStyle(style);
          }
          continue;
        }

        if (content.isCommited() == false)
        {
          throw new InvalidReportStateException("Uncommited content encountered");
        }

        final long contentOffset = contentProducer.getContentOffset(row, col);
        final TableRectangle rectangle = sheetLayout.getTableBounds
            (content.getX(), content.getY() + contentOffset,
                content.getWidth(), content.getHeight(), null);
        if (rectangle.isOrigin(col, row) == false)
        {
          // A spanned cell ..
          continue;
        }

        final CellBackground fastBackground = cellBackgroundProducer.getBackgroundForBox
            (logicalPage, sheetLayout, rectangle.getX1(), rectangle.getY1(),
                rectangle.getColumnSpan(), rectangle.getRowSpan(), false, sectionType, content);
        // export the cell and all content ..

        final Cell cell = getCellAt(col, row);
        final CellStyle style =
            getCellStyleProducer().createCellStyle(content.getInstanceId(), content.getStyleSheet(), fastBackground);
        if (style != null)
        {
          cell.setCellStyle(style);
        }

        if (applyCellValue(content, cell, sheetLayout, rectangle, contentOffset))
        {
          mergeCellRegion(rectangle, row, col, sheetLayout, logicalPage, content, contentProducer);
View Full Code Here

      for (int spannedCol = 0; spannedCol < columnSpan; spannedCol += 1)
      {
        final CellMarker.SectionType sectionType = contentProducer.getSectionType(row, col);
        final CellBackground bg = cellBackgroundProducer.getBackgroundForBox
            (logicalPage, sheetLayout, rectX + spannedCol, rectY + spannedRow, 1, 1, false, sectionType, content);
        final Cell regionCell = getCellAt((col + spannedCol), row + spannedRow);
        final CellStyle spannedStyle =
            getCellStyleProducer().createCellStyle(content.getInstanceId(), content.getStyleSheet(), bg);
        if (spannedStyle != null)
        {
          regionCell.setCellStyle(spannedStyle);
        }
      }
    }
  }
View Full Code Here

  }

  protected Cell getCellAt(final int x, final int y)
  {
    final Row row = getRowAt(y);
    final Cell cell = row.getCell(x);
    if (cell != null)
    {
      return cell;
    }
    return row.createCell(x);
View Full Code Here

  {
    for (final CellLayoutInfo layoutInfo : backgroundCells)
    {
      int col = layoutInfo.getX1();
      int row = layoutInfo.getY1();
      final Cell cell = getCellAt(col, row);
      final CellStyle style = getCellStyleProducer().createCellStyle(null, null, layoutInfo.getBackground());
      if (style != null)
      {
        cell.setCellStyle(style);
      }

    }

    if (band.getComputedStyle().getBooleanStyleProperty(BandStyleKeys.PAGEBREAK_AFTER))
View Full Code Here

  {
    TableRectangle rect = new TableRectangle();
    rect.setRect(tableRectangle.getX1(), tableRectangle.getY1() + rowOffset,
        tableRectangle.getX2(), tableRectangle.getY2() + rowOffset);

    Cell cellAt = getCellAt(rect.getX1(), rect.getY1());
    CellBackground bg = tableRectangle.getBackground();
    CellStyle cellStyle = getCellStyleProducer().createCellStyle(element.getObjectID(), element.getComputedStyle(), bg);
    if (cellStyle != null)
    {
      cellAt.setCellStyle(cellStyle);
    }
    if (applyCellValue(element, cellAt, rect, runtime))
    {
      mergeCellRegion(rect, cellStyle);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.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.