Example usage for org.apache.poi.hssf.usermodel HSSFWorkbook write

List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook write

Introduction

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

Prototype

private void write(POIFSFileSystem fs) throws IOException 

Source Link

Document

Writes the workbook out to a brand new, empty POIFS

Usage

From source file:dbedit.actions.ExportExcelAction.java

License:Open Source License

@Override
protected void performThreaded(ActionEvent e) throws Exception {
    boolean selection = false;
    JTable table = ResultSetTable.getInstance();
    if (table.getSelectedRowCount() > 0 && table.getSelectedRowCount() != table.getRowCount()) {
        Object option = Dialog.show("Excel", "Export", Dialog.QUESTION_MESSAGE,
                new Object[] { "Everything", "Selection" }, "Everything");
        if (option == null || "-1".equals(option.toString())) {
            return;
        }/*from w w  w.  j  av  a 2s  .co  m*/
        selection = "Selection".equals(option);
    }
    List list = ((DefaultTableModel) table.getModel()).getDataVector();
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet();
    HSSFRow row = sheet.createRow(0);
    HSSFCellStyle style = workbook.createCellStyle();
    style.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
    style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    HSSFFont font = workbook.createFont();
    font.setColor(HSSFColor.WHITE.index);
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    style.setFont(font);
    for (int i = 0; i < table.getColumnCount(); i++) {
        HSSFCell cell = row.createCell(i);
        cell.setCellValue(new HSSFRichTextString(table.getColumnName(i)));
        cell.setCellStyle(style);
        sheet.setColumnWidth(i, (table.getColumnModel().getColumn(i).getPreferredWidth() * 45));
    }
    int count = 1;
    for (int i = 0; i < list.size(); i++) {
        if (!selection || table.isRowSelected(i)) {
            List data = (List) list.get(i);
            row = sheet.createRow(count++);
            for (int j = 0; j < data.size(); j++) {
                Object o = data.get(j);
                HSSFCell cell = row.createCell(j);
                if (o instanceof Number) {
                    cell.setCellValue(((Number) o).doubleValue());
                } else if (o != null) {
                    if (ResultSetTable.isLob(j)) {
                        cell.setCellValue(
                                new HSSFRichTextString(Context.getInstance().getColumnTypeNames()[j]));
                    } else {
                        cell.setCellValue(new HSSFRichTextString(o.toString()));
                    }
                }
            }
        }
    }
    sheet.createFreezePane(0, 1);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    workbook.write(byteArrayOutputStream);
    FileIO.saveAndOpenFile("export.xls", byteArrayOutputStream.toByteArray());
}

From source file:de.bund.bfr.knime.openkrise.db.imports.custom.LieferkettenImporterEFSA.java

License:Open Source License

public boolean doImport(final String filename, final JProgressBar progress, final boolean showResults) {
    Runnable runnable = new Runnable() {
        public void run() {
            System.err.println("Importing " + filename);
            logMessages += "Importing " + filename + "\n";
            try {
                if (progress != null) {
                    progress.setVisible(true);
                    progress.setStringPainted(true);
                    progress.setString("Importiere Lieferketten Datei...");
                    progress.setMinimum(0);
                }// ww w .  j a v  a 2  s . c  o m

                loadNodeIDs10000();

                InputStream is = null;
                if (filename.startsWith("http://")) {
                    URL url = new URL(filename);
                    URLConnection uc = url.openConnection();
                    is = uc.getInputStream();
                } else if (filename.startsWith("/de/bund/bfr/knime/openkrise/db/res/")) {
                    is = getClass().getResourceAsStream(filename);
                } else {
                    is = new FileInputStream(filename);
                }

                POIFSFileSystem fs = new POIFSFileSystem(is);
                HSSFWorkbook wb = new HSSFWorkbook(fs);

                boolean transformFormat = false;
                int[] nsf = new int[2];
                if (filename.endsWith("LST_partners.xls")) {
                    if (transformFormat)
                        ;
                    else
                        nsf = doImportMaciel(wb, progress, "98"); // 98: LST
                } else if (filename.endsWith("ZAK_partners.xls")) {
                    if (transformFormat)
                        ;
                    else
                        nsf = doImportMaciel(wb, progress, "273"); // 273: ZAK
                } else if (filename.endsWith("NORIS.xls")) {
                    if (transformFormat)
                        ;
                    else
                        nsf = doImportMaciel(wb, progress, "115"); // 115: Noris
                } else if (filename.endsWith("agrifruct.xls")) {
                    if (transformFormat)
                        ;
                    else
                        nsf = doImportMaciel(wb, progress, "8"); // 8: Agrifruct
                } else if (filename.endsWith("Sunnyside_Suppliers.xls")) {
                    if (transformFormat)
                        ;
                    else
                        nsf = doImportMaciel(wb, progress, "238"); // 238: Sunnyside_Suppliers
                } else if (filename.endsWith("BfR_berry_supplier.xls")) {
                    if (transformFormat)
                        ;
                    else
                        nsf = doImportGaia(wb, progress);

                } else if (filename.endsWith("Erlenbacher.xls")) {
                    if (transformFormat)
                        ;
                    else
                        nsf = doImportErlenbacherFW(wb, progress, "1786");

                } else {
                    if (transformFormat) {
                        InputStream isNew = new FileInputStream(
                                "C:\\Users\\Armin\\Desktop\\AllKrisen\\NewFormat.xls");
                        POIFSFileSystem fsNew = new POIFSFileSystem(isNew);
                        HSSFWorkbook wbNew = new HSSFWorkbook(fsNew);
                        transformFormat(wb, wbNew);
                        File f = new File(filename);
                        File fd = new File(f.getParent() + "/NewFormat");
                        fd.mkdir();
                        FileOutputStream out = new FileOutputStream(
                                f.getParent() + "/NewFormat/" + f.getName());
                        wbNew.write(out);
                        /*
                         * RaspYog nochmal genauer checken dutch file when
                         * new format established
                         */
                    } else {
                        nsf = doImportStandard(wb, progress, filename);
                        //nsf = doImportNewFormat(wb, progress);
                    }
                }
                int numSuccess = nsf[0];
                int numFails = nsf[1];

                DBKernel.myDBi.getTable("Station").doMNs();
                DBKernel.myDBi.getTable("Produktkatalog").doMNs();
                DBKernel.myDBi.getTable("Chargen").doMNs();
                DBKernel.myDBi.getTable("Lieferungen").doMNs();
                if (progress != null) {
                    // Refreshen:
                    MyDBTable myDB = DBKernel.mainFrame.getMyList().getMyDBTable();
                    if (myDB.getActualTable() != null) {
                        String actTablename = myDB.getActualTable().getTablename();
                        if (actTablename.equals("Produktkatalog") || actTablename.equals("Lieferungen")
                                || actTablename.equals("Station") || actTablename.equals("Chargen")) {
                            myDB.setTable(myDB.getActualTable());
                        }
                    }
                    progress.setVisible(false);
                }
                if (showResults) {
                    String log = numSuccess + " erfolgreiche Importe.\n";
                    log += numFails + " fehlgeschlagene Importe.\n";
                    InfoBox ib = new InfoBox(log, true, new Dimension(300, 150), null);
                    ib.setVisible(true);
                }
            } catch (Exception e) {
                logMessages += "\nUnable to import file '" + filename
                        + "'.\nWrong file format?\nImporter says: \n" + e.toString() + "\n" + getST(e, true)
                        + "\n\n";
                MyLogger.handleException(e);
            }
            System.err.println("Importing - Fin");
            logMessages += "Importing - Fin" + "\n\n";
        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
    try {
        thread.join();
    } catch (InterruptedException e) {
        logMessages += "\nUnable to run thread for '" + filename + "'.\nWrong file format?\nImporter says: \n"
                + e.toString() + "\n" + getST(e, true) + "\n\n";
        MyLogger.handleException(e);
    }
    return true;
}

From source file:de.jwic.ecolib.tableviewer.export.ExcelExportControl.java

License:Apache License

public void attachResource(HttpServletRequest req, HttpServletResponse res) throws IOException {
    try {/*  ww w  .  j a v  a2  s . c  o m*/
        String filename = "export.xls";
        HSSFWorkbook wb = createWorkBook();

        res.setContentType("application/x-msdownload");
        res.setHeader("Content-Disposition", "attachment; filename=" + filename);
        wb.write(res.getOutputStream());
        res.getOutputStream().close();
    } catch (NoClassDefFoundError e) {
        log.error("Error generating workbook:", e);
    }
}

From source file:de.maklerpoint.office.Schnittstellen.Excel.ExportExcelXLS.java

License:Open Source License

/**
 * // ww  w .  j  av  a 2s . c om
 * @throws FileNotFoundException
 * @throws IOException
 */

public void write() throws FileNotFoundException, IOException {
    FileOutputStream out = new FileOutputStream(new File(filename));
    HSSFWorkbook wb;

    wb = new HSSFWorkbook();

    Map<String, HSSFCellStyle> styles = createStyles(wb);
    HSSFSheet sheet = wb.createSheet(sheetName);

    //turn off gridlines
    sheet.setDisplayGridlines(false);
    sheet.setPrintGridlines(false);
    sheet.setFitToPage(true);
    sheet.setHorizontallyCenter(true);
    HSSFPrintSetup printSetup = sheet.getPrintSetup();
    printSetup.setLandscape(true);

    sheet.setAutobreaks(true);
    printSetup.setFitHeight((short) 1);
    printSetup.setFitWidth((short) 1);

    HSSFRow headerRow = sheet.createRow(0);
    headerRow.setHeightInPoints(12.75f);

    int[][] width = new int[titles.length][titles.length];

    for (int i = 0; i < titles.length; i++) {
        HSSFCell cell = headerRow.createCell(i);
        cell.setCellValue(titles[i]);
        cell.setCellStyle(styles.get("header"));

        width[i][0] = titles[i].length();
    }

    HSSFRow row;
    HSSFCell cell;
    int rownum = 1;

    for (int i = 0; i < data.length; i++, rownum++) {
        row = sheet.createRow(rownum);
        if (data[i] == null)
            continue;

        for (int j = 0; j < data[i].length; j++) {
            cell = row.createCell(j);
            if (data[i][j] == null)
                data[i][j] = "";

            cell.setCellValue(data[i][j].toString());

            if (data[i][j].toString().length() > width[j][0])
                width[j][0] = data[i][j].toString().length();
        }
    }

    for (int i = 0; i < titles.length; i++) {
        int widthShort = (256 * (width[i][0] + 3));

        sheet.setColumnWidth(i, widthShort);
    }

    int position = (titles.length / 2) - 1;

    row = sheet.createRow(rownum + 3);
    cell = row.createCell(position);

    if (footName == null) {
        SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm");
        cell.setCellValue("Export MaklerPoint vom " + df.format(new Date(System.currentTimeMillis()))
                + " - www.maklerpoint.de");
    } else {
        cell.setCellValue(footName);
    }

    sheet.setZoom(3, 4);

    wb.write(out);
    out.close();
}

From source file:de.maklerpoint.office.Schnittstellen.Excel.ExportKalenderExcel.java

License:Open Source License

/**
 * // ww w  .jav a 2 s  .c  om
 * @throws FileNotFoundException
 * @throws IOException
 */

public void write() throws FileNotFoundException, IOException {
    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);

    HSSFWorkbook wb = new HSSFWorkbook();
    Map<String, HSSFCellStyle> styles = createStyles(wb);

    for (int month = 0; month < 12; month++) {
        calendar.set(Calendar.MONTH, month);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        //create a sheet for each month
        HSSFSheet sheet = wb.createSheet(months[month]);

        //turn off gridlines
        sheet.setDisplayGridlines(false);
        sheet.setPrintGridlines(false);
        sheet.setFitToPage(true);
        sheet.setHorizontallyCenter(true);
        HSSFPrintSetup printSetup = sheet.getPrintSetup();
        printSetup.setLandscape(true);

        //the following three statements are required only for HSSF
        sheet.setAutobreaks(true);
        printSetup.setFitHeight((short) 1);
        printSetup.setFitWidth((short) 1);

        //the header row: centered text in 48pt font
        HSSFRow headerRow = sheet.createRow(0);
        headerRow.setHeightInPoints(80);
        HSSFCell titleCell = headerRow.createCell(0);
        titleCell.setCellValue(months[month] + " " + year);
        titleCell.setCellStyle(styles.get("title"));
        //                sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$N$1"));

        //header with month titles
        HSSFRow monthRow = sheet.createRow(1);
        for (int i = 0; i < days.length; i++) {
            //set column widths, the width is measured in units of 1/256th of a character width
            sheet.setColumnWidth((i * 2), (5 * 256)); //the column is 5 characters wide
            sheet.setColumnWidth((i * 2 + 1), (13 * 256)); //the column is 13 characters wide
            //sheet.addMergedRegion(new Region(1, (short) 1, i*2, (short) (i * 2 + 1)));
            sheet.addMergedRegion(new CellRangeAddress(1, i * 2, 1, (i * 2 + 1))); // TODO Test
            HSSFCell monthCell = monthRow.createCell((i * 2));
            monthCell.setCellValue(days[i]);
            monthCell.setCellStyle(styles.get("month"));
        }

        int cnt = 1, day = 1;
        int rownum = 2;
        for (int j = 0; j < 6; j++) {
            HSSFRow row = sheet.createRow(rownum++);
            row.setHeightInPoints(100);
            for (int i = 0; i < days.length; i++) {
                HSSFCell dayCell_1 = row.createCell((i * 2));
                HSSFCell dayCell_2 = row.createCell((i * 2 + 1));

                int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
                if (cnt >= day_of_week && calendar.get(Calendar.MONTH) == month) {
                    dayCell_1.setCellValue(day);
                    calendar.set(Calendar.DAY_OF_MONTH, ++day);

                    if (i == 0 || i == days.length - 1) {
                        dayCell_1.setCellStyle(styles.get("weekend_left"));
                        dayCell_2.setCellStyle(styles.get("weekend_right"));
                    } else {
                        dayCell_1.setCellStyle(styles.get("workday_left"));
                        dayCell_2.setCellStyle(styles.get("workday_right"));
                    }
                } else {
                    dayCell_1.setCellStyle(styles.get("grey_left"));
                    dayCell_2.setCellStyle(styles.get("grey_right"));
                }
                cnt++;
            }
            if (calendar.get(Calendar.MONTH) > month)
                break;
        }
    }

    // Write the output to a file        

    FileOutputStream out = new FileOutputStream(this.filename);
    wb.write(out);
    out.close();
}

From source file:de.powerstaff.web.backingbean.profile.ProfileBackingBean.java

License:Open Source License

public void commandSearchExportExcel() {
    try {//w  w w  .  ja v  a 2s. c o  m
        FacesContext theContext = FacesContext.getCurrentInstance();

        ExternalContext externalContext = theContext.getExternalContext();
        HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();

        response.reset(); // Some JSF component library or some Filter might have set some headers in the buffer beforehand. We want to get rid of them, else it may collide.
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-disposition", "attachment; filename=\"ExportSuche.xls\"");

        HSSFWorkbook theWorkbook = new HSSFWorkbook();
        HSSFSheet theWorkSheet = theWorkbook.createSheet("ExportSuche");

        HSSFCellStyle theDateStyle = theWorkbook.createCellStyle();
        theDateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("d/m/jj"));

        int aRow = 0;
        // Header
        HSSFRow theRow = theWorkSheet.createRow(aRow++);
        ExcelUtils.addCellToRow(theRow, 0, "Anrede");
        ExcelUtils.addCellToRow(theRow, 1, "Name1");
        ExcelUtils.addCellToRow(theRow, 2, "Name2");
        ExcelUtils.addCellToRow(theRow, 3, "eMail");
        ExcelUtils.addCellToRow(theRow, 4, "Code");
        ExcelUtils.addCellToRow(theRow, 5, "Verfgbarkeit");
        ExcelUtils.addCellToRow(theRow, 6, "Satz");
        ExcelUtils.addCellToRow(theRow, 7, "Plz");
        ExcelUtils.addCellToRow(theRow, 8, "Letzter Kontakt");
        ExcelUtils.addCellToRow(theRow, 9, "Skills");
        ExcelUtils.addCellToRow(theRow, 10, "Tags");

        // Rows
        PagedListDataModel<ProfileSearchEntry> theData = getData().getSearchResult();
        for (int i = 0; i < theData.getRowCount() && i < profileSearchService.getPageSize(); i++) {
            theData.setRowIndex(i);

            ProfileSearchEntry theDataRow = (ProfileSearchEntry) theData.getRowData();

            Freelancer theFreelancer = freelancerService.findByPrimaryKey(theDataRow.getFreelancer().getId());

            String theSkills = ExcelUtils.saveObject(
                    theFreelancer.getSkills().replace("\f", "").replace("\n", "").replace("\t", ""));

            StringBuilder theTagList = new StringBuilder();
            for (FreelancerToTag theTagAssignment : theFreelancer.getTags()) {
                if (theTagList.length() > 0) {
                    theTagList.append(" ");
                }
                theTagList.append(theTagAssignment.getTag().getName());
            }

            HSSFRow theFreelancerRow = theWorkSheet.createRow(aRow++);
            ExcelUtils.addCellToRow(theFreelancerRow, 0, ExcelUtils.saveObject(theFreelancer.getTitel()));
            ExcelUtils.addCellToRow(theFreelancerRow, 1, ExcelUtils.saveObject(theFreelancer.getName1()));
            ExcelUtils.addCellToRow(theFreelancerRow, 2, ExcelUtils.saveObject(theFreelancer.getName2()));
            ExcelUtils.addCellToRow(theFreelancerRow, 3,
                    ExcelUtils.saveObject(theFreelancer.getFirstContactEMail())); // eMail
            ExcelUtils.addCellToRow(theFreelancerRow, 4, ExcelUtils.saveObject(theFreelancer.getCode()));
            ExcelUtils.addCellToRow(theFreelancerRow, 5,
                    ExcelUtils.saveObject(theFreelancer.getAvailabilityAsDate()), theDateStyle);
            ExcelUtils.addCellToRow(theFreelancerRow, 6, ExcelUtils.saveObject(theFreelancer.getSallaryLong()));
            ExcelUtils.addCellToRow(theFreelancerRow, 7, ExcelUtils.saveObject(theFreelancer.getPlz()));
            ExcelUtils.addCellToRow(theFreelancerRow, 8,
                    ExcelUtils.saveObject(theFreelancer.getLastContactDate()), theDateStyle);
            ExcelUtils.addCellToRow(theFreelancerRow, 9, ExcelUtils.saveObject(theSkills));
            ExcelUtils.addCellToRow(theFreelancerRow, 10, theTagList.toString());
        }

        theWorkbook.write(response.getOutputStream());

        theContext.responseComplete(); // Important!

    } catch (Exception e) {
        JSFMessageUtils.addGlobalErrorMessage(MSG_FEHLERBEIDERPROFILSUCHE, e.getMessage());
        LOGGER.error("Fehler bei Profilsuche", e);
    }
}

From source file:de.sub.goobi.forms.ProjekteForm.java

License:Open Source License

/**
 * Create excel./*from  w  w  w  .ja  v a 2  s . c  o  m*/
 */
public void createExcel() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (!facesContext.getResponseComplete()) {

        /*
         * Vorbereiten der Header-Informationen
         */
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
        try {
            ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
            String contentType = servletContext.getMimeType("export.xls");
            response.setContentType(contentType);
            response.setHeader("Content-Disposition", "attachment;filename=\"export.xls\"");
            ServletOutputStream out = response.getOutputStream();
            HSSFWorkbook wb = (HSSFWorkbook) this.myCurrentTable.getExcelRenderer().getRendering();
            wb.write(out);
            out.flush();
            facesContext.responseComplete();
        } catch (IOException e) {
            logger.error(e);
        }
    }
}

From source file:de.sub.goobi.forms.ProzessverwaltungForm.java

License:Open Source License

/**
 * Create excel.//from ww  w .j  a  v a 2  s  .co m
 */
public void CreateExcel() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (!facesContext.getResponseComplete()) {

        /*
         * Vorbereiten der Header-Informationen
         */
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
        try {
            ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
            String contentType = servletContext.getMimeType("export.xls");
            response.setContentType(contentType);
            response.setHeader("Content-Disposition", "attachment;filename=\"export.xls\"");
            ServletOutputStream out = response.getOutputStream();
            HSSFWorkbook wb = (HSSFWorkbook) this.myCurrentTable.getExcelRenderer().getRendering();
            wb.write(out);
            out.flush();
            facesContext.responseComplete();

        } catch (IOException e) {
            logger.error(e);
        }
    }
}

From source file:de.sub.goobi.forms.ProzessverwaltungForm.java

License:Open Source License

/**
 * Generate result set.//from w ww.  j a  v  a  2 s .co  m
 */
public void generateResult() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (!facesContext.getResponseComplete()) {

        /*
         * Vorbereiten der Header-Informationen
         */
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
        try {
            ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
            String contentType = servletContext.getMimeType("search.xls");
            response.setContentType(contentType);
            response.setHeader("Content-Disposition", "attachment;filename=\"search.xls\"");
            ServletOutputStream out = response.getOutputStream();
            SearchResultGeneration sr = new SearchResultGeneration(this.filter, this.showClosedProcesses,
                    this.showArchivedProjects);
            HSSFWorkbook wb = sr.getResult();
            wb.write(out);
            out.flush();
            facesContext.responseComplete();
        } catch (IOException e) {
            logger.error(e);
        }
    }
}

From source file:de.thorstenberger.taskmodel.impl.ReportBuilderImpl.java

License:Open Source License

public void createExcelBinary(long taskId, OutputStream out)
        throws TaskApiException, MethodNotSupportedException {

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();//from   ww  w  . ja  va2  s  .  c  o  m
    TaskDef taskDef = taskManager.getTaskDef(taskId);

    short r = 0;
    short c = 0;

    List<Tasklet> tasklets = taskManager.getTaskletContainer().getTasklets(taskId);

    ///////////////////
    // create header
    HSSFRow row = sheet.createRow(r++);
    row.createCell(c++).setCellValue("Login");
    row.createCell(c++).setCellValue("Vorname");
    row.createCell(c++).setCellValue("Name");
    List<UserAttribute> uas = taskManager.availableUserAttributes();
    for (UserAttribute ua : uas) {
        row.createCell(c++).setCellValue(ua.getName(null));
    }
    row.createCell(c++).setCellValue("Status");

    // add header cols for automatic and manual corrections
    row.createCell(c++).setCellValue("autom. Korrektur");
    // determine number of correctors
    int maxManualCorrectors = 0;
    for (Tasklet tasklet : tasklets) {
        List<ManualCorrection> mcs = tasklet.getTaskletCorrection().getManualCorrections();
        if (mcs != null && mcs.size() > maxManualCorrectors) {
            maxManualCorrectors = mcs.size();
        }
    }

    // ok, so add header cols for every corrector, as determined above
    for (int i = 1; i <= maxManualCorrectors; i++) {
        row.createCell(c++).setCellValue("Punkte " + i + ". Korrektor");
    }
    for (int i = 1; i <= maxManualCorrectors; i++) {
        row.createCell(c++).setCellValue("Name " + i + ". Korrektor");
    }

    row.createCell(c++).setCellValue("zugeordneter Korrektor");
    row.createCell(c++).setCellValue("Zuordnungs-History");

    // add some more columns, if complex task; e.g. points per category
    if (taskDef instanceof TaskDef_Complex) {

        row.createCell(c++).setCellValue("Startzeit");

        TaskDef_Complex ctd = (TaskDef_Complex) taskDef;
        List<Category> categories = ctd.getComplexTaskDefRoot().getCategoriesList();
        for (Category category : categories) {
            row.createCell(c++).setCellValue(category.getTitle() + " (" + category.getId() + ")");
        }

    }

    // show tasklet flags
    row.createCell(c++).setCellValue("Flags");

    // end create header
    //////////////////////

    for (Tasklet tasklet : tasklets) {

        if (tasklet.getStatus() == Tasklet.Status.INITIALIZED) {
            continue;
        }

        row = sheet.createRow(r++);
        c = 0;

        c = createUserInfoColumns(tasklet, c, wb, row);
        row.createCell(c++).setCellValue(tasklet.getStatus().toString());

        // auto correction points
        row.createCell(c++)
                .setCellValue(tasklet.getTaskletCorrection().getAutoCorrectionPoints() != null
                        ? "" + tasklet.getTaskletCorrection().getAutoCorrectionPoints()
                        : "-");
        List<ManualCorrection> mcs = tasklet.getTaskletCorrection().getManualCorrections();
        for (int i = 0; i < maxManualCorrectors; i++) {
            if (mcs != null && mcs.size() > i) {
                row.createCell(c++).setCellValue(mcs.get(i).getPoints());
            } else {
                row.createCell(c++).setCellValue("-");
            }
        }
        for (int i = 0; i < maxManualCorrectors; i++) {
            if (mcs != null && mcs.size() > i) {
                row.createCell(c++).setCellValue(mcs.get(i).getCorrector());
            } else {
                row.createCell(c++).setCellValue("-");
            }
        }

        row.createCell(c++)
                .setCellValue(tasklet.getTaskletCorrection().getCorrector() != null
                        ? tasklet.getTaskletCorrection().getCorrector()
                        : "-");
        row.createCell(c++).setCellValue(tasklet.getTaskletCorrection().getCorrectorHistory().toString());

        // add the additional cols for complex tasks
        if (taskDef instanceof TaskDef_Complex) {

            TaskDef_Complex ctd = (TaskDef_Complex) taskDef;
            //            if( ctd.getComplexTaskDefRoot().getCorrectionMode().getType() == ComplexTaskDefRoot.CorrectionModeType.MULTIPLECORRECTORS )
            //               throw new IllegalStateException( "MultiCorrectorMode not supported yet. Stay tuned!" );

            ComplexTasklet ct = (ComplexTasklet) tasklet;
            row.createCell(c++).setCellValue(getStringFromMillis(ct.getSolutionOfLatestTry().getStartTime()));

            List<Category> categories = ctd.getComplexTaskDefRoot().getCategoriesList();

            // points per category
            Map<String, Float> pointsInCatMap = new Hashtable<String, Float>();

            // init every category with 0 points
            for (Category category : categories) {
                pointsInCatMap.put(category.getId(), 0f);
            }

            Try studentsLastTry;

            try {
                studentsLastTry = ct.getSolutionOfLatestTry();
            } catch (IllegalStateException e) {
                log.error("Error generating excel stream: ", e);
                throw new TaskApiException(e);
            }

            List<Page> pages = studentsLastTry.getPages();

            for (Page page : pages) {
                Float points = pointsInCatMap.get(page.getCategoryRefId());

                // continue if marked as uncorrected earlier
                if (points == null) {
                    continue;
                }

                boolean markCategoryAsUncorrected = false;

                List<SubTasklet> subTasklets = page.getSubTasklets();
                for (SubTasklet subTasklet : subTasklets) {
                    if (subTasklet.isCorrected()) {
                        points += subTasklet.isAutoCorrected() ? subTasklet.getAutoCorrection().getPoints()
                                : subTasklet.getManualCorrections().get(0).getPoints();
                    } else {
                        markCategoryAsUncorrected = true;
                        break;
                    }
                }

                if (markCategoryAsUncorrected) {
                    pointsInCatMap.remove(page.getCategoryRefId());
                } else {
                    pointsInCatMap.put(page.getCategoryRefId(), points);
                }

            }

            for (Category category : categories) {
                Float points = pointsInCatMap.get(category.getId());
                row.createCell(c++).setCellValue(points != null ? "" + points : "-");
            }

        }

        row.createCell(c++).setCellValue(tasklet.getFlags().toString());

    }

    try {
        wb.write(out);
        out.flush();
    } catch (IOException e) {
        log.error("Error writing excel stream!", e);
        throw new TaskApiException(e);
    } finally {
        try {
            out.close();
        } catch (IOException e) {
            throw new TaskApiException(e);
        }
    }

}