Example usage for org.apache.poi.hssf.usermodel HSSFSheet getSheetName

List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet getSheetName

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFSheet getSheetName.

Prototype

@SuppressWarnings("resource")
@Override
public String getSheetName() 

Source Link

Document

Returns the name of this sheet

Usage

From source file:org.kopsox.spreadsheet.data.excel.ExcelWorkbook.java

License:Open Source License

@Override
public Sheet createNewSheet() {

    HSSFSheet newSheet = workbook.createSheet();

    ExcelSheet es = new ExcelSheet(this, newSheet, newSheet.getSheetName(), workbook.getSheetIndex(newSheet));

    registerSheet(newSheet.getSheetName(), es);

    return es;//from  ww w.  j av  a  2 s  . c  o m
}

From source file:org.kopsox.spreadsheet.data.excel.ExcelWorkbook.java

License:Open Source License

@Override
public Sheet createNewSheet(String name) {
    HSSFSheet newSheet = workbook.createSheet(name);

    ExcelSheet es = new ExcelSheet(this, newSheet, newSheet.getSheetName(), workbook.getSheetIndex(newSheet));

    registerSheet(name, es);// ww  w  .  j a v a2  s.  c  om

    return es;
}

From source file:org.kopsox.spreadsheet.data.excel.ExcelWorkbook.java

License:Open Source License

@Override
public Sheet getSheetByName(String name) {
    if (name == null) {
        return null;
    }/*from   w  w  w  . j a  v  a  2s  . c om*/

    if (!containsSheet(name)) {
        HSSFSheet sheet = workbook.getSheet(name);

        if (sheet == null) {
            return null;
        }

        registerSheet(name, new ExcelSheet(this, sheet, sheet.getSheetName(), workbook.getSheetIndex(sheet)));
    }

    return getSheet(name);
}

From source file:org.openelis.bean.QcChartReport1Bean.java

License:Open Source License

private void finishSheet(HSSFSheet sheet, HSSFWorkbook wb, String qcName, String qcType, String sheetName) {
    int i, columnIndex;
    ArrayList<DictionaryDO> tempQcColumns;
    DictionaryDO dict;//from  w ww  .  j  a v a 2s .c o  m
    HashSet<Integer> emptyColumns;
    Name rangeName;
    Row row;
    String rangeFormula;

    if (qcColumns != null && !qcColumns.isEmpty())
        row = sheet.getRow(32);
    else
        row = sheet.getRow(3);
    emptyColumns = new HashSet<Integer>();
    for (i = 0; i < row.getLastCellNum(); i++) {
        if (i >= maxChars.size() || maxChars.get(i) == 0)
            emptyColumns.add(i);
    }

    setHeaderCells(sheet, qcName, qcType, sheetName);

    if (qcColumns != null && !qcColumns.isEmpty()) {
        tempQcColumns = new ArrayList<DictionaryDO>();
        tempQcColumns.addAll(qcColumns);
        for (i = tempQcColumns.size() - 1; i > -1; i--) {
            if (emptyColumns.contains(i + 5)) {
                tempQcColumns.remove(i);
                removeColumn(sheet, i + 5);
                maxChars.remove(i + 5);
            }
        }

        rangeName = getName(wb, sheet, "RowNumber");
        if (rangeName == null) {
            rangeName = wb.createName();
            rangeName.setSheetIndex(wb.getSheetIndex(sheet));
            rangeName.setNameName("RowNumber");
        }
        rangeFormula = sheet.getSheetName() + "!$" + CellReference.convertNumToColString(0) + "$33:" + "$"
                + CellReference.convertNumToColString(0) + "$" + (sheet.getLastRowNum() + 1);
        rangeName.setRefersToFormula(rangeFormula);

        /*
         * Create named ranges for the graph to be able to locate the appropriate
         * data
         */
        columnIndex = 5;
        for (i = 0; i < tempQcColumns.size(); i++) {
            dict = tempQcColumns.get(i);
            if (!DataBaseUtil.isEmpty(dict.getCode())) {
                rangeName = getName(wb, sheet, dict.getCode());
                if (rangeName == null) {
                    rangeName = wb.createName();
                    rangeName.setSheetIndex(wb.getSheetIndex(sheet));
                    rangeName.setNameName(dict.getCode());
                }
                rangeFormula = rangeName.getRefersToFormula();
                if (rangeFormula != null && rangeFormula.length() > 0
                        && !"$A$2".equals(rangeFormula.substring(rangeFormula.indexOf("!") + 1)))
                    rangeFormula += ",";
                else
                    rangeFormula = "";
                rangeFormula += sheet.getSheetName() + "!$" + CellReference.convertNumToColString(columnIndex)
                        + "$33:" + "$" + CellReference.convertNumToColString(columnIndex) + "$"
                        + (sheet.getLastRowNum() + 1);
                rangeName.setRefersToFormula(rangeFormula);
            }
            columnIndex++;
        }
        /*
         * make each column wide enough to show the longest string in it; the
         * width for each column is set as the maximum number of characters in
         * that column multiplied by 256; this is because the default width of
         * one character is 1/256 units in Excel
         */
        for (i = 5; i < maxChars.size(); i++)
            sheet.setColumnWidth(i, maxChars.get(i) * 256);
    } else if (worksheetHeaders != null && worksheetHeaders.size() > 0) {
        /*
         * make each column wide enough to show the longest string in it; the
         * width for each column is set as the maximum number of characters in
         * that column multiplied by 256; this is because the default width of
         * one character is 1/256 units in Excel
         */
        for (i = 0; i < maxChars.size(); i++)
            sheet.setColumnWidth(i, maxChars.get(i) * 256);
    }

    wb.setSheetName(wb.getSheetIndex(sheet), sheetName);
    sheet.setForceFormulaRecalculation(true);
    maxChars.clear();
}

From source file:org.openelis.bean.QcChartReport1Bean.java

License:Open Source License

private HSSFName getName(HSSFWorkbook wb, HSSFSheet sheet, String nameString) {
    int i;/*w  ww  .j av a 2 s.  c o m*/
    HSSFName name;

    for (i = 0; i < wb.getNumberOfNames(); i++) {
        name = wb.getNameAt(i);
        if (name.getNameName().equals(nameString) && name.getSheetName().equals(sheet.getSheetName()))
            return name;
    }

    return null;
}

From source file:org.openelis.bean.WorksheetExcelHelperBean.java

License:Open Source License

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
private int createResultCellsForFormat(HSSFSheet sheet, Row row, Row tRow, String nameIndexPrefix,
        HashMap<String, String> cellNames, WorksheetViewDO wVDO, WorksheetAnalysisViewDO waVDO,
        ArrayList<WorksheetResultViewDO> wrList, boolean isEditable,
        HashMap<String, HashMap<Integer, ArrayList<AnalyteParameterViewDO>>> apMap) {
    int c, i, r;/*from w  ww  . ja  va2  s  .  c o m*/
    String cellNameIndex, name;
    ArrayList<AnalyteParameterViewDO> anaParams, apList;
    DecimalFormat df;
    HashMap<Integer, ArrayList<AnalyteParameterViewDO>> pMap;
    Cell cell, tCell;
    Name cellName;
    AnalyteParameterViewDO apVDO;

    df = new DecimalFormat();
    df.setGroupingUsed(false);
    df.setMaximumFractionDigits(10);

    i = 0;
    r = row.getRowNum();
    for (WorksheetResultViewDO wrVDO : wrList) {
        if (i != 0) {
            row = sheet.createRow(r);
            for (c = 0; c < 7; c++) {
                cell = row.createCell(c);
                cell.setCellStyle(styles.get("row_no_edit"));
            }
        }

        cellNameIndex = nameIndexPrefix + "." + i;

        // analyte
        cell = row.createCell(7);
        cell.setCellStyle(styles.get("row_no_edit"));
        cell.setCellValue(wrVDO.getAnalyteName());

        // reportable
        cell = row.createCell(8);
        cell.setCellStyle(styles.get("row_no_edit"));
        cell.setCellValue(wrVDO.getIsReportable());
        cellName = sheet.getWorkbook().createName();
        cellName.setNameName("analyte_reportable." + cellNameIndex);
        cellName.setRefersToFormula(
                "Worksheet!$" + CellReference.convertNumToColString(8) + "$" + (row.getRowNum() + 1));

        apVDO = null;
        for (c = 9; c < tRow.getLastCellNum() && c < 39; c++) {
            tCell = tRow.getCell(c);

            cell = row.createCell(c);
            if (isEditable)
                cell.setCellStyle(tCell.getCellStyle());
            else
                cell.setCellStyle(styles.get("row_no_edit"));
            name = cellNames.get(
                    sheet.getSheetName() + "!$" + CellReference.convertNumToColString(tCell.getColumnIndex())
                            + "$" + (tCell.getRowIndex() + 1));
            if (name != null) {
                cellName = row.getSheet().getWorkbook().createName();
                cellName.setNameName(name + "." + cellNameIndex);
                cellName.setRefersToFormula(
                        sheet.getSheetName() + "!$" + CellReference.convertNumToColString(cell.getColumnIndex())
                                + "$" + (row.getRowNum() + 1));
            }
            if (tCell.getCellType() == Cell.CELL_TYPE_FORMULA && tCell.getCellFormula() != null) {
                cell.setCellFormula(tCell.getCellFormula());
            } else {
                setCellValue(cell, wrVDO.getValueAt(c - 9));
            }
            if ("p1".equals(name) || "p2".equals(name) || "p3".equals(name) || "p_1".equals(name)
                    || "p_2".equals(name) || "p_3".equals(name)) {
                if (wrVDO.getValueAt(c - 9) == null) {
                    pMap = apMap.get("T" + waVDO.getTestId());
                    if (pMap == null) {
                        pMap = new HashMap<Integer, ArrayList<AnalyteParameterViewDO>>();
                        apMap.put("T" + waVDO.getTestId(), pMap);
                        try {
                            anaParams = analyteParameter.fetchByActiveDate(waVDO.getTestId(),
                                    Constants.table().TEST, wVDO.getCreatedDate().getDate());
                            for (AnalyteParameterViewDO anaParam : anaParams) {
                                apList = pMap.get(anaParam.getAnalyteId());
                                if (apList == null) {
                                    apList = new ArrayList<AnalyteParameterViewDO>();
                                    pMap.put(anaParam.getAnalyteId(), apList);
                                }
                                apList.add(anaParam);
                            }
                        } catch (NotFoundException nfE) {
                            continue;
                        } catch (Exception anyE) {
                            log.log(Level.SEVERE,
                                    "Error retrieving analyte parameters for an analysis on worksheet.", anyE);
                            continue;
                        }
                    }

                    apList = pMap.get(wrVDO.getAnalyteId());
                    apVDO = null;
                    if (apList != null && apList.size() > 0) {
                        for (AnalyteParameterViewDO ap : apList) {
                            if (ap.getUnitOfMeasureId() == null
                                    || ap.getUnitOfMeasureId().equals(waVDO.getUnitOfMeasureId())) {
                                if (ap.getUnitOfMeasureId() != null) {
                                    apVDO = ap;
                                    break;
                                } else if (apVDO == null) {
                                    apVDO = ap;
                                }
                            }
                        }
                    }
                    if (apVDO != null) {
                        if (("p1".equals(name) || "p_1".equals(name)) && apVDO.getP1() != null) {
                            setCellValue(cell, df.format(apVDO.getP1()));
                        } else if (("p2".equals(name) || "p_2".equals(name)) && apVDO.getP2() != null) {
                            setCellValue(cell, df.format(apVDO.getP2()));
                        } else if (("p3".equals(name) || "p_3".equals(name)) && apVDO.getP3() != null) {
                            setCellValue(cell, df.format(apVDO.getP3()));
                        }
                    }
                }
            }
        }

        i++;
        r++;
    }

    return r;
}

From source file:org.openelis.bean.WorksheetExcelHelperBean.java

License:Open Source License

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
private int createQcResultCellsForFormat(HSSFSheet sheet, Row row, Row tRow, String nameIndexPrefix,
        HashMap<String, String> cellNames, WorksheetViewDO wVDO, Integer qcId,
        ArrayList<WorksheetQcResultViewDO> wqrList,
        HashMap<String, HashMap<Integer, ArrayList<AnalyteParameterViewDO>>> apMap) {
    int c, i, r;// w  ww.j  av a  2  s .  c om
    String cellNameIndex, name;
    ArrayList<AnalyteParameterViewDO> anaParams, apList;
    DecimalFormat df;
    HashMap<Integer, ArrayList<AnalyteParameterViewDO>> pMap;
    Cell cell, tCell;
    Name cellName;
    AnalyteParameterViewDO apVDO;

    df = new DecimalFormat();
    df.setGroupingUsed(false);
    df.setMaximumFractionDigits(10);

    i = 0;
    r = row.getRowNum();
    for (WorksheetQcResultViewDO wqrVDO : wqrList) {
        if (i != 0) {
            row = sheet.createRow(r);
            for (c = 0; c < 7; c++) {
                cell = row.createCell(c);
                cell.setCellStyle(styles.get("row_no_edit"));
            }
        }

        cellNameIndex = nameIndexPrefix + "." + i;

        // analyte
        cell = row.createCell(7);
        cell.setCellStyle(styles.get("row_no_edit"));
        cell.setCellValue(wqrVDO.getAnalyteName());

        // reportable
        cell = row.createCell(8);
        cell.setCellStyle(styles.get("row_no_edit"));
        cell.setCellValue("N");

        apVDO = null;
        for (c = 9; c < tRow.getLastCellNum() && c < 39; c++) {
            tCell = tRow.getCell(c);

            cell = row.createCell(c);
            cell.setCellStyle(tCell.getCellStyle());
            name = cellNames.get(
                    sheet.getSheetName() + "!$" + CellReference.convertNumToColString(tCell.getColumnIndex())
                            + "$" + (tCell.getRowIndex() + 1));
            if (name != null) {
                cellName = row.getSheet().getWorkbook().createName();
                cellName.setNameName(name + "." + cellNameIndex);
                cellName.setRefersToFormula(
                        sheet.getSheetName() + "!$" + CellReference.convertNumToColString(cell.getColumnIndex())
                                + "$" + (row.getRowNum() + 1));
            }
            if (tCell.getCellType() == Cell.CELL_TYPE_FORMULA && tCell.getCellFormula() != null) {
                cell.setCellFormula(tCell.getCellFormula());
            } else {
                setCellValue(cell, wqrVDO.getValueAt(c - 9));
            }
            if ("p1".equals(name) || "p2".equals(name) || "p3".equals(name) || "p_1".equals(name)
                    || "p_2".equals(name) || "p_3".equals(name)) {
                if (wqrVDO.getValueAt(c - 9) == null) {
                    pMap = apMap.get("Q" + qcId);
                    if (pMap == null) {
                        pMap = new HashMap<Integer, ArrayList<AnalyteParameterViewDO>>();
                        apMap.put("Q" + qcId, pMap);
                        try {
                            anaParams = analyteParameter.fetchByActiveDate(qcId, Constants.table().QC,
                                    wVDO.getCreatedDate().getDate());
                            for (AnalyteParameterViewDO anaParam : anaParams) {
                                apList = pMap.get(anaParam.getAnalyteId());
                                if (apList == null) {
                                    apList = new ArrayList<AnalyteParameterViewDO>();
                                    pMap.put(anaParam.getAnalyteId(), apList);
                                }
                                apList.add(anaParam);
                            }
                        } catch (NotFoundException nfE) {
                            continue;
                        } catch (Exception anyE) {
                            log.log(Level.SEVERE, "Error retrieving analyte parameters for a qc on worksheet.",
                                    anyE);
                            continue;
                        }
                    }

                    apList = pMap.get(wqrVDO.getAnalyteId());
                    apVDO = null;
                    if (apList != null && apList.size() > 0)
                        apVDO = apList.get(0);
                    if (apVDO != null) {
                        if (("p1".equals(name) || "p_1".equals(name)) && apVDO.getP1() != null) {
                            setCellValue(cell, String.valueOf(apVDO.getP1()));
                        } else if (("p2".equals(name) || "p_2".equals(name)) && apVDO.getP2() != null) {
                            setCellValue(cell, String.valueOf(apVDO.getP2()));
                        } else if (("p3".equals(name) || "p_3".equals(name)) && apVDO.getP3() != null) {
                            setCellValue(cell, String.valueOf(apVDO.getP3()));
                        }
                    }
                }
            }
        }

        i++;
        r++;
    }

    return r;
}

From source file:org.projectforge.business.fibu.datev.BuchungssatzExcelImporter.java

License:Open Source License

private ImportedSheet<BuchungssatzDO> importBuchungssaetze(final ExcelImport<BuchungssatzImportRow> imp,
        final HSSFSheet sheet, final int month) throws Exception {
    final ImportedSheet<BuchungssatzDO> importedSheet = new ImportedSheet<BuchungssatzDO>();
    imp.setNameRowIndex(ROW_COLUMNNAMES);
    imp.setStartingRowIndex(ROW_COLUMNNAMES + 1);
    imp.setRowClass(BuchungssatzImportRow.class);

    final Map<String, String> map = new HashMap<String, String>();
    map.put("SatzNr.", "satzNr");
    map.put("Satz-Nr.", "satzNr");
    map.put("Betrag", "betrag");
    map.put("SH", "sh"); // Nicht eindeutig!
    map.put("Konto", "konto");
    map.put("Kostenstelle/-trger", "kost2");
    map.put("Kost2", "kost2");
    map.put("Menge", "menge");
    map.put("SH2", "sh2");
    map.put("Beleg", "beleg");
    map.put("Datum", "datum");
    map.put("Gegenkonto", "gegenkonto");
    map.put("Text", "text");
    map.put("Alt.-Kst.", "kost1");
    map.put("Kost1", "kost1");
    map.put("Beleg 2", "beleg2");
    map.put("KR-BSNr.", "kr_bsnr");
    map.put("ZI", "zi");
    map.put("Kommentar", "comment");
    map.put("Bemerkung", "comment");
    imp.setColumnMapping(map);//  w  w w . j a v  a 2  s  .  co m

    BuchungssatzImportRow[] rows = new BuchungssatzImportRow[0];
    rename2ndSH(sheet);
    rows = imp.convertToRows(BuchungssatzImportRow.class);
    if (rows == null || rows.length == 0) {
        return null;
    }
    int year = 0;
    for (int i = 0; i < rows.length; i++) {
        ImportedElement<BuchungssatzDO> element;
        try {
            element = convertBuchungssatz(rows[i]);
        } catch (final RuntimeException ex) {
            throw new RuntimeException(
                    "Im Blatt '" + sheet.getSheetName() + "', in Zeile " + (i + 2) + ": " + ex.getMessage(),
                    ex);
        }
        if (element == null) {
            // Empty row:
            continue;
        }
        final BuchungssatzDO satz = element.getValue();
        final DateHolder date = new DateHolder(satz.getDatum(), DatePrecision.DAY, Locale.GERMAN);
        if (year == 0) {
            year = date.getYear();
        } else if (year != date.getYear()) {
            final String msg = "Not supported: Buchungsstze innerhalb eines Excel-Sheets liegen in verschiedenen Jahren: Im Blatt '"
                    + sheet.getSheetName() + "', in Zeile " + (i + 2);
            actionLog.logError(msg);
            throw new UserException(msg);
        }
        if (date.getMonth() > month) {
            final String msg = "Buchungsstze knnen nicht in die Zukunft fr den aktuellen Monat '"
                    + KostFormatter.formatBuchungsmonat(year, date.getMonth()) + " gebucht werden! " + satz;
            actionLog.logError(msg);
            throw new RuntimeException(msg);
        } else if (date.getMonth() < month) {
            final String msg = "Buchungssatz liegt vor Monat '" + KostFormatter.formatBuchungsmonat(year, month)
                    + "' (OK): " + satz;
            actionLog.logInfo(msg);
        }
        satz.setYear(year);
        satz.setMonth(month);
        importedSheet.addElement(element);
        log.debug(satz);
    }
    importedSheet.setName(KostFormatter.formatBuchungsmonat(year, month));
    importedSheet.setProperty("year", year);
    importedSheet.setProperty("month", month);
    return importedSheet;
}

From source file:org.projectforge.excel.ExcelImport.java

License:Open Source License

/**
 * convert the contents of the table into an array.
 * /*  w  ww  . j  ava2s  .c o m*/
 * @param clazz the target class
 * @return an array with the object values.
 */
@SuppressWarnings("unchecked")
public T[] convertToRows(final Class<T> clazz) {
    if (clazzFactory == null) {
        setRowClass(clazz);
    }
    final HSSFSheet sheet = work.getSheetAt(activeSheet);
    final int numberOfRows = sheet.getLastRowNum();
    final List<T> list = new ArrayList<T>(numberOfRows);
    final HSSFRow columnNames = sheet.getRow(columnNameRow);
    for (int i = startAtRow; i <= numberOfRows; i++) {
        try {
            T line;
            line = convertToBean(sheet.getRow(i), columnNames, i + 1);
            if (line == null) {
                continue;
            }
            if (clazz.isInstance(line) == false) {
                throw new IllegalStateException("returned type " + line.getClass() + " is not assignable to "
                        + clazz + " in sheet='" + sheet.getSheetName() + "', row=" + i);
            }
            list.add(line);
        } catch (final InstantiationException ex) {
            throw new IllegalArgumentException("Can't create bean " + ex.toString() + " in sheet='"
                    + sheet.getSheetName() + "', row=" + i);
        } catch (final IllegalAccessException ex) {
            throw new IllegalArgumentException("Getter is not visible " + ex.toString() + " in sheet='"
                    + sheet.getSheetName() + "', row=" + i);
        } catch (final InvocationTargetException ex) {
            log.error(ex.getMessage(), ex);
            throw new IllegalArgumentException("Getter threw an exception " + ex.toString() + " in sheet='"
                    + sheet.getSheetName() + "', row=" + i);
        } catch (final NoSuchMethodException ex) {
            throw new IllegalArgumentException("Getter is not existant " + ex.toString() + " in sheet='"
                    + sheet.getSheetName() + "', row=" + i);
        }
    }
    return list.toArray((T[]) Array.newInstance(clazz, 0));
}

From source file:org.projectforge.fibu.datev.BuchungssatzExcelImporter.java

License:Open Source License

private ImportedSheet<BuchungssatzDO> importBuchungssaetze(final ExcelImport<BuchungssatzImportRow> imp,
        final HSSFSheet sheet, final int month) throws Exception {
    final ImportedSheet<BuchungssatzDO> importedSheet = new ImportedSheet<BuchungssatzDO>();
    imp.setNameRowIndex(ROW_COLUMNNAMES);
    imp.setStartingRowIndex(ROW_COLUMNNAMES + 1);
    imp.setRowClass(BuchungssatzImportRow.class);

    final Map<String, String> map = new HashMap<String, String>();
    map.put("SatzNr.", "satzNr");
    map.put("Satz-Nr.", "satzNr");
    map.put("Betrag", "betrag");
    map.put("SH", "sh"); // Nicht eindeutig!
    map.put("Konto", "konto");
    map.put("Kostenstelle/-trger", "kost2");
    map.put("Kost2", "kost2");
    map.put("Menge", "menge");
    map.put("SH2", "sh2");
    map.put("Beleg", "beleg");
    map.put("Datum", "datum");
    map.put("Gegenkonto", "gegenkonto");
    map.put("Text", "text");
    map.put("Alt.-Kst.", "kost1");
    map.put("Kost1", "kost1");
    map.put("Beleg 2", "beleg2");
    map.put("KR-BSNr.", "kr_bsnr");
    map.put("ZI", "zi");
    map.put("Kommentar", "comment");
    map.put("Bemerkung", "comment");
    imp.setColumnMapping(map);/*from w  ww. j a  v  a2  s .c  om*/

    BuchungssatzImportRow[] rows = new BuchungssatzImportRow[0];
    rename2ndSH(sheet);
    rows = imp.convertToRows(BuchungssatzImportRow.class);
    if (rows == null || rows.length == 0) {
        return null;
    }
    int year = 0;
    for (int i = 0; i < rows.length; i++) {
        ImportedElement<BuchungssatzDO> element;
        try {
            element = convertBuchungssatz(rows[i]);
        } catch (final RuntimeException ex) {
            throw new RuntimeException(
                    "Im Blatt '" + sheet.getSheetName() + "', in Zeile " + (i + 2) + ": " + ex.getMessage(),
                    ex);
        }
        if (element == null) {
            // Empty row:
            continue;
        }
        final BuchungssatzDO satz = element.getValue();
        final DateHolder date = new DateHolder(satz.getDatum(), DatePrecision.DAY, Locale.GERMAN);
        if (year == 0) {
            year = date.getYear();
        } else if (year != date.getYear()) {
            final String msg = "Not supported: Buchungsstze innerhalb eines Excel-Sheets liegen in verschiedenen Jahren.";
            actionLog.logError(msg);
            throw new UserException(msg);
        }
        if (date.getMonth() > month) {
            final String msg = "Buchungsstze knnen nicht in die Zukunft fr den aktuellen Monat '"
                    + KostFormatter.formatBuchungsmonat(year, date.getMonth()) + " gebucht werden! " + satz;
            actionLog.logError(msg);
            throw new RuntimeException(msg);
        } else if (date.getMonth() < month) {
            final String msg = "Buchungssatz liegt vor Monat '" + KostFormatter.formatBuchungsmonat(year, month)
                    + "' (OK): " + satz;
            actionLog.logInfo(msg);
        }
        satz.setYear(year);
        satz.setMonth(month);
        importedSheet.addElement(element);
        log.debug(satz);
    }
    importedSheet.setName(KostFormatter.formatBuchungsmonat(year, month));
    importedSheet.setProperty("year", year);
    importedSheet.setProperty("month", month);
    return importedSheet;
}