Examples of HSSFRow


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

    sheet = getSheet(wb, 10, new int[] { 7000, 1400, 1400, 1200, 1500,
        1500, 1900, 1300, 1000, 3000 });

    int currentRow = 0;
    HSSFRow row;

    CellStyle cellStyle = new CellStyle(wb);

    Set<Transport> transports = tableModels.keySet();
    List<Transport> sortedTransport = new ArrayList<Transport>(transports);
View Full Code Here

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

    sheet = getSheet(wb, 9, new int[] { 7000, 1400, 1400, 1200, 1500, 1500,
        1900, 1300, 1000 });

    int currentRow = 0;
    HSSFRow row;
    Map<Integer, HSSFRow> rader = new HashMap<Integer, HSSFRow>();

    CellStyle cellStyle = new CellStyle(wb);

    short addColumn = -1;
View Full Code Here

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

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet;

    sheet = wb.createSheet("sheet");
    int currentRow = 0;
    HSSFRow row;
    HSSFCell cell;

    CellStyle cellStyle = new CellStyle(wb, (short) headFontSize);

    // Overskrift
    if (heading != null && heading.length() != 0) {
      row = sheet.createRow((short) currentRow++);
      createCell(row, cellStyle.getHeadingStyle(), (short) 0, heading);
    }

    // Kolonneoverskrift
    row = sheet.createRow((short) currentRow++);
    int columnCount = table.getColumnCount();
    int rowCount = table.getRowCount();

    // Skriver ut kolonneoverskrift
    createColumnHeadings(row, cellStyle.getHeadingStyle(),
        table.getModel(), 0, columnCount, 0, notVisibleColumns);

    String groupValue = "";
    List<ExcelGroupSum> formulaCells = new ArrayList<ExcelGroupSum>();
    String groupSumValue = "";
    ExcelGroupSum currentExcelGroupSum = null;

    // Data
    int j;
    int k;
    int l = currentRow;
    // G�r gjennom alle rader og kolonner
    for (j = currentRow; j < rowCount + currentRow; j++) {
      // dersom data skal grupperes
      if (groupColumn != null
          && !table.getValueAt(j - currentRow, groupColumn).equals(
              groupValue)) {
        // setter forrige grupperingssum
        if (currentExcelGroupSum != null) {
          currentExcelGroupSum.setToRow((short) (l));
          formulaCells.add(currentExcelGroupSum);
          groupSumValue = "";
          currentExcelGroupSum = null;
        }
        // henter grupperingsverdi og setter ny overskrift for
        // gruppering
        groupValue = (String) table.getValueAt(j - currentRow,
            groupColumn);
        row = sheet.createRow((short) l);
        createCell(row, cellStyle.getGroupStyle(), (short) 0,
            groupValue);
        sheet.addMergedRegion(new Region((short) l, (short) 0,
            (short) l,
            (short) (columnCount - notVisibleColumnsSize - 1)));
        l++;

      }
      setLabelInfo(labelInfo, infoString, j);

      row = sheet.createRow((short) l);
      l++;

      // g�r gjennom alle kolonner for rad
      for (k = 0; k < columnCount; k++) {
        // dersom kolonne skal v�re synlig
        if (notVisibleColumns == null || !notVisibleColumns.contains(k)) {
          // dersom kolonnebredde er satt
          if (colSize != null) {
            Integer columnSize = colSize.get(k);
            if (columnSize != null) {
              sheet.setColumnWidth((short) k, columnSize
                  .shortValue());
            }
          }
          cell = row.createCell((short) k);
          // dersom celle har verdi
          if (table.getValueAt(j - currentRow, k) != null) {

            // dersom det er grupperingssum satt og den er ulik
            // forrige
            if (groupSumValueColumn != null
                && !table.getValueAt(j - currentRow,
                    groupSumValueColumn).equals(
                    groupSumValue)) {
              groupSumValue = (String) table.getValueAt(j
                  - currentRow, groupSumValueColumn);

              short dayColorIndex = DayEnum
                  .getDayColorIndex(groupSumValue);

              if (currentExcelGroupSum != null) {
                currentExcelGroupSum.setToRow((short) (l - 1));
                formulaCells.add(currentExcelGroupSum);
              }
              if (groupResultColumn != null) {
                currentExcelGroupSum = new ExcelGroupSum(
                    (short) l, row
                        .createCell(groupResultColumn
                            .shortValue()),
                    groupSumColumn.shortValue(),
                    dayColorIndex, wb.createCellStyle());
              }
View Full Code Here

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

    HSSFWorkbook wb = new HSSFWorkbook();

    HSSFSheet sheet = getSheet(wb, 1, new int[] { 4000 });

    int currentRow = 0;
    HSSFRow row;

    CellStyle cellStyle = new CellStyle(wb);

    row = sheet.createRow((short) currentRow++);
View Full Code Here

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

      final String infoString, final HSSFSheet sheet,
      final int rowNumber, final CellStyle cellStyle,
      final short weekAdd,
      final Map<Transport, TransportOverviewTableModel> models,
      final Transport transport, final Map<Integer, HSSFRow> rader) {
    HSSFRow row;
    int currentRow = rowNumber;

    TableModel tableModel = models.get(transport);

    row = rader.get(currentRow);
View Full Code Here

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

  private int setCellData(final JLabel labelInfo, final String infoString,
      final HSSFSheet sheet, final int currentRow,
      final CellStyle cellStyle, final TableModel tableModel,
      final short weekAdd, final int columnCount, final int j,
      Map<Integer, HSSFRow> rader) {
    HSSFRow row;
    int k;
    setLabelInfo(labelInfo, infoString, j);
    row = rader.get(j);
    if (row == null) {
      row = sheet.createRow((short) j);
View Full Code Here

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

    HSSFSheet sheet = wb.createSheet("sheet");

    int currentRow = 0;
    int startCell = 0;

    HSSFRow row;

    CellStyle cellStyle = new CellStyle(wb, (short) headFontSize);

    // Overskrift
    if (heading != null && heading.length() != 0) {
View Full Code Here

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

    }

    currentRow = setInfoText(excelSheet, infoTextTop, startCell,
        currentRow, cellStyle.getStyle10Bold());

    HSSFRow row = excelSheet.createRow((short) currentRow++);
    int columnCount = table.getColumnCount();
    int rowCount = table.getRowCount();
    // kolonne som har blitt lagt til pga utskrift av radnummer
    int addedColumn = 0;
    // dersom radnummer skal skrives ut
    if (writeRowNumber) {
      excelSheet.setColumnWidth((short) 0, (short) 900);
      startCell += 1;
      if (groupSumColumn != null) {
        groupSumColumn += 1;
      }
      addedColumn = 1;
    }
    // Skriver ut kolonneoverskrift
    createColumnHeadings(row, cellStyle.getHeadingStyle(),
        table.getModel(), 0, columnCount, startCell, notVisibleColumns);
    // Data
    int j;
    int k;
    int l = currentRow;
    int rowNumber = 0;

    // det skal legges til en summeringsformel p� sluttet
    if (sumFormula != null) {
      sumFormula.setFromRow(l + 1);
    }
    HSSFCell cell;
    String groupValue = "";
    List<ExcelGroupSum> formulaCells = new ArrayList<ExcelGroupSum>();
    String groupSumValue = "";
    ExcelGroupSum currentExcelGroupSum = null;
    // G�r gjennom alle rader og kolonner
    for (j = currentRow; j < rowCount + currentRow; j++) {
      rowNumber++;
      // dersom data skal grupperes
      if (groupColumn != null
          && !table.getValueAt(j - currentRow, groupColumn).equals(
              groupValue)) {
        // setter forrige grupperingssum
        if (currentExcelGroupSum != null) {
          currentExcelGroupSum.setToRow((short) (l));
          formulaCells.add(currentExcelGroupSum);
          groupSumValue = "";
          currentExcelGroupSum = null;
          rowNumber = 1;
        }
        // henter grupperingsverdi og setter ny overskrift for
        // gruppering
        groupValue = (String) table.getValueAt(j - currentRow,
            groupColumn);
        row = excelSheet.createRow((short) l);

        createCell(row, cellStyle.getGroupStyle(),
            (short) (startCell - addedColumn), groupValue);
        excelSheet.addMergedRegion(new Region((short) l, (short) 0,
            (short) l, (short) (columnCount + addedColumn
                - notVisibleColumnsSize - 1)));
        l++;

      }
      setLabelInfo(labelInfo, infoString, j);
      row = excelSheet.createRow((short) l);
      l++;
      // dersom det skal skrives ut rad nummer
      if (writeRowNumber) {
        cell = row.createCell((short) (startCell - 1));
        cell.setCellValue(rowNumber);
      }
      // g�r gjennom alle kolonner for rad
      for (k = startCell; k < columnCount + startCell; k++) {
        // dersom kolonne skal v�re synlig
        if (notVisibleColumns == null
            || !notVisibleColumns.contains(k - startCell)) {
          setColumnSize(colSize, excelSheet, startCell, addedColumn,
              k);
          cell = row.createCell((short) k);
          // dersom celle har verdi
          if (table.getValueAt(j - currentRow, k - startCell) != null) {
            // dersom det er grupperingssum satt og den er ulik
            // forrige
            if (groupSumValueColumn != null
                && !table.getValueAt(j - currentRow,
                    groupSumValueColumn).equals(
                    groupSumValue)) {

              groupSumValue = (String) table.getValueAt(j
                  - currentRow, groupSumValueColumn);
              if (currentExcelGroupSum != null) {
                currentExcelGroupSum.setToRow((short) (l - 1));
                formulaCells.add(currentExcelGroupSum);
              }
              if (groupResultColumn != null
                  && groupSumColumn != null) {
                currentExcelGroupSum = new ExcelGroupSum(
                    (short) l,
                    row
                        .createCell((short) (groupResultColumn
                            .shortValue() + addedColumn)),
                    groupSumColumn.shortValue(),
                    DayEnum.getDayColorIndex(groupSumValue),
                    wb.createCellStyle());
View Full Code Here

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

  }

  private static int setInfoText(final HSSFSheet excelSheet,
      final String infoText, final int startCell,
      final int currentRowNumber, final HSSFCellStyle cellStyle) {
    HSSFRow row;
    int l = currentRowNumber;
    if (infoText != null) {
      row = excelSheet.createRow((short) l);
      l++;
View Full Code Here

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

  private static int setSumFormula(final HSSFSheet excelSheet,
      final ExcelSumFormula sumFormula, final CellStyle cellStyle,
      final int addedColumn, final int currentRowNumber,
      final int maxColumn, final int startCell) {
    HSSFRow row;
    HSSFCell cell;
    int l = currentRowNumber;
    if (sumFormula != null
        && sumFormula.getToRow() > sumFormula.getFromRow()) {
      row = excelSheet.createRow((short) l);

      l++;

      List<Integer> sumColumns = sumFormula.getSumColumns();
      // int counter = 0;
      int tmpMaxColumn = maxColumn + startCell;
      int ignoreCell = 0;
      for (int i = startCell; i <= tmpMaxColumn; i++) {

        // for (Integer column : sumColumns) {
        /*
         * counter++; if (counter == 1) { if (sumFormula.getInfoText()
         * != null) { createCell(row, cellStyle.getHeadingStyle(),
         * (short) (sumFormula.getInfoColumn()),
         * sumFormula.getInfoText()); } }
         */

        if (sumColumns.contains(Integer.valueOf(i))) {
          createCell(row, cellStyle.getHeadingStyle(), (short) i, "");
          cell = row.createCell((short) (i + startCell));
          String columnLetter = getColLetter(i + startCell);
          ignoreCell = i + startCell;

          cell.setCellFormula("sum(" + columnLetter
              + sumFormula.getFromRow() + ":" + columnLetter
              + sumFormula.getToRow() + ")");
          cell.setCellStyle(cellStyle.getHeadingStyle());
        } else {
          String text = i == startCell
              && sumFormula.getInfoText() != null ? sumFormula
              .getInfoText() : "";
          if (i != ignoreCell) {
            createCell(row, cellStyle.getHeadingStyle(), (short) i,
                text);
          }
        }
      }

      if (sumFormula.getSumLineFormulaColumn() != null) {
        cell = row.createCell(sumFormula.getSumLineFormulaColumn()
            .shortValue());
        cell.setCellFormula(sumFormula.getSumLineFormula());
        cell.setCellStyle(cellStyle.getHeadingStyle());
      }
    }
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.