protected void exportFrame(
      TableBuilder tableBuilder, JRPrintFrame frame, JRExporterGridCell gridCell)
      throws IOException, JRException {
    tableBuilder.buildCellHeader(
        styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan());

    boolean appendBackcolor =
        frame.getModeValue() == ModeEnum.OPAQUE
            && (backcolor == null || frame.getBackcolor().getRGB() != backcolor.getRGB());

    if (appendBackcolor) {
      setBackcolor(frame.getBackcolor());
    }

    try {
      JRGridLayout layout = gridCell.getLayout();
      JRPrintElementIndex frameIndex =
          new JRPrintElementIndex(reportIndex, pageIndex, gridCell.getWrapper().getAddress());
      exportGrid(layout, frameIndex);
    } finally {
      if (appendBackcolor) {
        restoreBackcolor();
      }
    }

    tableBuilder.buildCellFooter();
  }
 protected JRPrintElementIndex getElementIndex(JRExporterGridCell gridCell) {
   JRPrintElementIndex imageIndex =
       new JRPrintElementIndex(reportIndex, pageIndex, gridCell.getWrapper().getAddress());
   return imageIndex;
 }
  protected void exportGrid(JRGridLayout gridLayout, JRPrintElementIndex frameIndex)
      throws IOException, JRException {
    CutsInfo xCuts = gridLayout.getXCuts();
    JRExporterGridCell[][] grid = gridLayout.getGrid();

    TableBuilder tableBuilder =
        frameIndex == null
            ? new TableBuilder(reportIndex, pageIndex, tempBodyWriter, tempStyleWriter)
            : new TableBuilder(frameIndex.toString(), tempBodyWriter, tempStyleWriter);

    tableBuilder.buildTableStyle(gridLayout.getWidth());
    tableBuilder.buildTableHeader();

    for (int col = 1; col < xCuts.size(); col++) {
      tableBuilder.buildColumnStyle(col - 1, xCuts.getCutOffset(col) - xCuts.getCutOffset(col - 1));
      tableBuilder.buildColumnHeader(col - 1);
      tableBuilder.buildColumnFooter();
    }

    JRPrintElement element = null;
    for (int row = 0; row < grid.length; row++) {
      int emptyCellColSpan = 0;
      int emptyCellWidth = 0;
      int rowHeight = gridLayout.getRowHeight(row);

      tableBuilder.buildRowStyle(row, rowHeight);
      tableBuilder.buildRowHeader(row);

      for (int col = 0; col < grid[0].length; col++) {
        JRExporterGridCell gridCell = grid[row][col];
        if (gridCell.getType() == JRExporterGridCell.TYPE_OCCUPIED_CELL) {
          if (emptyCellColSpan > 0) {
            // writeEmptyCell(gridCell, emptyCellColSpan, emptyCellWidth, rowHeight);
            emptyCellColSpan = 0;
            emptyCellWidth = 0;
          }

          // writeOccupiedCells(1);
          exportOccupiedCells(1);
          //					OccupiedGridCell occupiedGridCell = (OccupiedGridCell)gridCell;
          //					ElementGridCell elementGridCell =
          // (ElementGridCell)grid[occupiedGridCell.getRow()][occupiedGridCell.getCol()];
          //					exportOccupiedCells(elementGridCell);
          //					col += elementGridCell.getColSpan() - 1;
        } else if (gridCell.getWrapper() != null) {
          if (emptyCellColSpan > 0) {
            // writeEmptyCell(gridCell, emptyCellColSpan, emptyCellWidth, rowHeight);
            emptyCellColSpan = 0;
            emptyCellWidth = 0;
          }

          element = gridCell.getWrapper().getElement();

          if (element instanceof JRPrintLine) {
            exportLine(tableBuilder, (JRPrintLine) element, gridCell);
          } else if (element instanceof JRPrintRectangle) {
            exportRectangle(tableBuilder, (JRPrintRectangle) element, gridCell);
          } else if (element instanceof JRPrintEllipse) {
            exportEllipse(tableBuilder, (JRPrintEllipse) element, gridCell);
          } else if (element instanceof JRPrintImage) {
            exportImage(tableBuilder, (JRPrintImage) element, gridCell);
          } else if (element instanceof JRPrintText) {
            exportText(tableBuilder, (JRPrintText) element, gridCell);
          } else if (element instanceof JRPrintFrame) {
            exportFrame(tableBuilder, (JRPrintFrame) element, gridCell);
          } else if (element instanceof JRGenericPrintElement) {
            exportGenericElement(tableBuilder, (JRGenericPrintElement) element, gridCell);
          }

          // //x += gridCell.colSpan - 1;
          // col += gridCell.getColSpan() - 1;
        } else {
          emptyCellColSpan++;
          emptyCellWidth += gridCell.getWidth();
          exportEmptyCell(gridCell, 1);
        }
      }

      //			if (emptyCellColSpan > 0)
      //			{
      //				//writeEmptyCell(null, emptyCellColSpan, emptyCellWidth, rowHeight);
      //			}

      tableBuilder.buildRowFooter();
    }

    tableBuilder.buildTableFooter();
  }