Example usage for org.apache.poi.ss.usermodel Workbook getCreationHelper

List of usage examples for org.apache.poi.ss.usermodel Workbook getCreationHelper

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Workbook getCreationHelper.

Prototype

CreationHelper getCreationHelper();

Source Link

Document

Returns an object that handles instantiating concrete classes of the various instances one needs for HSSF and XSSF.

Usage

From source file:Account.java

public void writetoexcel() throws FileNotFoundException, IOException {
    refresh();//  ww w  . j a  v a2s  .  c  o  m
    selection();
    DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
    DefaultTableModel dt = (DefaultTableModel) jTable2.getModel();
    DefaultTableModel d = (DefaultTableModel) jTable3.getModel();
    Workbook wb = new HSSFWorkbook();
    //XSSFWorkbook wb = new XSSFWorkbook();
    CreationHelper createhelper = wb.getCreationHelper();
    Sheet sheet = wb.createSheet("new sheet");
    Row row = null;
    Cell cell = null;
    row = sheet.createRow(0);
    cell = row.createCell(0);
    cell.setCellValue(jTextField1.getText());
    cell = row.createCell(6);
    cell.setCellValue("Replacement");

    row = sheet.createRow(1);
    cell = row.createCell(0);
    cell.setCellValue("Date");
    cell = row.createCell(6);
    cell.setCellValue("Date");

    cell = row.createCell(1);
    cell.setCellValue("Goods");
    cell = row.createCell(2);
    cell.setCellValue("Quantity");
    cell = row.createCell(3);
    cell.setCellValue("Rate");
    cell = row.createCell(4);
    cell.setCellValue("Total");

    cell = row.createCell(7);
    cell.setCellValue("Goods");
    cell = row.createCell(8);
    cell.setCellValue("Quantity");
    cell = row.createCell(9);
    cell.setCellValue("Rate");
    cell = row.createCell(10);
    cell.setCellValue("Total");

    int t = dtm.getRowCount();
    int m = dt.getRowCount();
    int y = d.getRowCount();
    int i, z;
    if (dtm.getValueAt(t - 1, 1) != null)
        t++;
    if (dt.getValueAt(m - 1, 1) != null)
        m++;
    if (d.getValueAt(y - 1, 0) != null)
        y++;
    if (t < m) {
        z = m;
        for (i = 0; i < t - 1; i++) {
            row = sheet.createRow(i + 2);
            for (int j = 0; j < dtm.getColumnCount(); j++) {

                cell = row.createCell(j);
                if (j == 4)
                    cell.setCellValue((Long) dtm.getValueAt(i, j));
                else if (j == 0 || j == 1)
                    cell.setCellValue((String) dtm.getValueAt(i, j));
                else
                    cell.setCellValue((Integer) dtm.getValueAt(i, j));

                cell = row.createCell(j + 6);
                if (j == 4)
                    cell.setCellValue((Long) dt.getValueAt(i, j));
                else if (j == 0 || j == 1)
                    cell.setCellValue((String) dt.getValueAt(i, j));
                else
                    cell.setCellValue(Integer.parseInt(dt.getValueAt(i, j).toString()));
            }
        }
        //i--;
        row = sheet.createRow(t + 2);
        cell = row.createCell(2);
        cell.setCellValue(jTextField3.getText());
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField4.getText()));

        row = sheet.createRow(t + 3);
        cell = row.createCell(2);
        cell.setCellValue(jTextField5.getText());
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField6.getText()));

        row = sheet.createRow(t + 4);
        cell = row.createCell(2);
        cell.setCellValue(jTextField7.getText());
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField8.getText()));

        row = sheet.createRow(t + 5);
        cell = row.createCell(2);
        cell.setCellValue("Total Replacement");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField10.getText()));

        row = sheet.createRow(t + 6);
        cell = row.createCell(2);
        cell.setCellValue("Total");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField13.getText()));

        row = sheet.createRow(t + 7);
        cell = row.createCell(2);
        cell.setCellValue("Payment Total");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField16.getText()));

        row = sheet.createRow(t + 8);
        cell = row.createCell(2);
        cell.setCellValue("New Grand Total");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField20.getText()));

        int k = i;
        while (i <= m - 1) {
            row = sheet.createRow(i + 2);
            if (i == k + 1) {
                cell = row.createCell(2);
                cell.setCellValue(jTextField3.getText());
                cell = row.createCell(4);
                cell.setCellValue(Long.parseLong(jTextField4.getText()));
            }

            if (i == k + 2) {
                cell = row.createCell(2);
                cell.setCellValue(jTextField5.getText());
                cell = row.createCell(4);
                cell.setCellValue(Long.parseLong(jTextField6.getText()));

            }

            if (i == k + 3) {
                cell = row.createCell(2);
                cell.setCellValue(jTextField7.getText());
                cell = row.createCell(4);
                cell.setCellValue(Long.parseLong(jTextField8.getText()));
            }

            if (i == k + 4) {
                cell = row.createCell(2);
                cell.setCellValue("Total Replacement");
                cell = row.createCell(4);
                cell.setCellValue(Long.parseLong(jTextField10.getText()));
            }

            if (i == k + 5) {
                cell = row.createCell(2);
                cell.setCellValue("Total");
                cell = row.createCell(4);
                cell.setCellValue(Long.parseLong(jTextField13.getText()));
            }

            if (i == k + 6) {
                cell = row.createCell(2);
                cell.setCellValue("Payment Total");
                cell = row.createCell(4);
                cell.setCellValue(Long.parseLong(jTextField16.getText()));
            }
            if (i == k + 7) {
                cell = row.createCell(2);
                cell.setCellValue("New Grand Total");
                cell = row.createCell(4);
                cell.setCellValue(Long.parseLong(jTextField20.getText()));
            }
            if (i == m - 1) {
                cell = row.createCell(8);
                cell.setCellValue("Total Replacement");
                cell = row.createCell(10);
                cell.setCellValue(Long.parseLong(jTextField10.getText()));
            } else {
                for (int j = 0; j < dtm.getColumnCount(); j++) {

                    cell = row.createCell(j + 6);
                    if (j == 4)
                        cell.setCellValue((Long) dt.getValueAt(i, j));
                    else if (j == 0 || j == 1)
                        cell.setCellValue((String) dt.getValueAt(i, j));
                    else
                        cell.setCellValue(Integer.parseInt(dt.getValueAt(i, j).toString()));
                }
            }
            i++;
        }
        row = sheet.createRow(m + 9);
        cell = row.createCell(0);
        cell.setCellValue("Payment");
        row = sheet.createRow(m + 10);
        cell = row.createCell(0);
        cell.setCellValue("Date");
        cell = row.createCell(1);
        cell.setCellValue("Payments");
        for (int u = 0; u < y - 1; u++) {
            row = sheet.createRow(u + m + 11);
            for (int j = 0; j < d.getColumnCount(); j++) {

                cell = row.createCell(j);
                if (j == 0)
                    cell.setCellValue((String) d.getValueAt(u, j));
                else
                    cell.setCellValue(Integer.parseInt(d.getValueAt(u, j).toString()));
            }
        }
        row = sheet.createRow(m + 11 + y);
        cell = row.createCell(0);
        cell.setCellValue("Payment Total");
        cell = row.createCell(1);
        cell.setCellValue(Long.parseLong(jTextField16.getText()));
    } else {
        for (i = 0; i < m - 1; i++) {
            row = sheet.createRow(i + 2);
            for (int j = 0; j < dtm.getColumnCount(); j++) {

                cell = row.createCell(j);
                if (j == 4)
                    cell.setCellValue((Long) dtm.getValueAt(i, j));
                else if (j == 0 || j == 1)
                    cell.setCellValue((String) dtm.getValueAt(i, j));
                else
                    cell.setCellValue((Integer) dtm.getValueAt(i, j));

                cell = row.createCell(j + 6);
                if (j == 4)
                    cell.setCellValue((Long) dt.getValueAt(i, j));
                else if (j == 0 || j == 1)
                    cell.setCellValue((String) dt.getValueAt(i, j));
                else
                    cell.setCellValue(Integer.parseInt(dt.getValueAt(i, j).toString()));
            }
        }
        //i--;
        int k = i;
        while (i <= t - 1) {
            row = sheet.createRow(i + 2);
            if (i == k) {
                cell = row.createCell(8);
                cell.setCellValue("Total Replacement");
                cell = row.createCell(10);
                cell.setCellValue(Long.parseLong(jTextField10.getText()));
            }
            if (i != t - 1) {
                for (int j = 0; j < dtm.getColumnCount(); j++) {

                    cell = row.createCell(j);
                    if (j == 4)
                        cell.setCellValue((Long) dtm.getValueAt(i, j));
                    else if (j == 0 || j == 1)
                        cell.setCellValue((String) dtm.getValueAt(i, j));
                    else
                        cell.setCellValue((Integer) dtm.getValueAt(i, j));
                }
            }
            i++;
        }
        row = sheet.createRow(t + 2);
        cell = row.createCell(2);
        cell.setCellValue(jTextField3.getText());
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField4.getText()));

        row = sheet.createRow(t + 3);
        cell = row.createCell(2);
        cell.setCellValue(jTextField5.getText());
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField6.getText()));

        row = sheet.createRow(t + 4);
        cell = row.createCell(2);
        cell.setCellValue(jTextField7.getText());
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField8.getText()));

        row = sheet.createRow(t + 5);
        cell = row.createCell(2);
        cell.setCellValue("Total Replacement");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField10.getText()));

        row = sheet.createRow(t + 6);
        cell = row.createCell(2);
        cell.setCellValue("Total");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField13.getText()));

        row = sheet.createRow(t + 7);
        cell = row.createCell(2);
        cell.setCellValue("Payment Total");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField16.getText()));

        row = sheet.createRow(t + 8);
        cell = row.createCell(2);
        cell.setCellValue("New Grand Total");
        cell = row.createCell(4);
        cell.setCellValue(Long.parseLong(jTextField20.getText()));

        row = sheet.createRow(t + 10);
        cell = row.createCell(0);
        cell.setCellValue("Payment");
        row = sheet.createRow(t + 11);
        cell = row.createCell(0);
        cell.setCellValue("Date");
        cell = row.createCell(1);
        cell.setCellValue("Payments");
        for (int u = 0; u < y - 1; u++) {
            row = sheet.createRow(u + t + 12);
            for (int j = 0; j < d.getColumnCount(); j++) {

                cell = row.createCell(j);
                if (j == 0)
                    cell.setCellValue((String) d.getValueAt(u, j));
                else
                    cell.setCellValue(Integer.parseInt(d.getValueAt(u, j).toString()));
            }
        }
        row = sheet.createRow(t + y + 12);
        cell = row.createCell(0);
        cell.setCellValue("Payment Total");
        cell = row.createCell(1);
        cell.setCellValue(Long.parseLong(jTextField16.getText()));
    }

    FileOutputStream out = new FileOutputStream(
            chooser.getSelectedFile() + "\\" + jTextField1.getText() + ".xls");
    wb.write(out);
    out.close();
}

From source file:Account.java

public void writereplacement() throws FileNotFoundException, IOException {
    DefaultTableModel dtm = (DefaultTableModel) jTable2.getModel();
    Workbook wb = new HSSFWorkbook();
    //XSSFWorkbook wb = new XSSFWorkbook();
    CreationHelper createhelper = wb.getCreationHelper();
    Sheet sheet = wb.createSheet("new sheet");
    Row row = null;/*from w  w  w.  j a v  a 2 s  .c om*/
    Cell cell = null;
    row = sheet.createRow(0);
    cell = row.createCell(6);
    cell.setCellValue("Replacement");
    row = sheet.createRow(1);
    cell = row.createCell(6);
    cell.setCellValue("Date");
    cell = row.createCell(7);
    cell.setCellValue("Goods");
    cell = row.createCell(8);
    cell.setCellValue("Quantity");
    cell = row.createCell(9);
    cell.setCellValue("Rate");
    cell = row.createCell(10);
    cell.setCellValue("Total");
    int t = dtm.getRowCount();
    if (dtm.getValueAt(t - 1, 1) != null)
        t++;
    for (int i = 0; i < t - 1; i++) {
        row = sheet.createRow(i + 2);
        for (int j = 0; j < dtm.getColumnCount(); j++) {

            cell = row.createCell(j + 6);
            if (j == 4)
                cell.setCellValue((Long) dtm.getValueAt(i, j));
            else if (j == 0 || j == 1)
                cell.setCellValue((String) dtm.getValueAt(i, j));
            else
                cell.setCellValue((Integer) dtm.getValueAt(i, j));
        }
    }

    row = sheet.createRow(t + 2);
    cell = row.createCell(2 + 6);
    cell.setCellValue("Replacement Total");
    cell = row.createCell(4 + 6);
    cell.setCellValue(Long.parseLong(jTextField10.getText()));

    FileOutputStream out = new FileOutputStream("D:\\workbook.xls");
    wb.write(out);
    out.close();
}

From source file:PlacasClientes.java

private void EnviarExcel(ResultSet rs) throws IOException {
    String rutaArchivo = System.getProperty("user.home") + "/ejemploExcelJava.xls";
    /*Se crea el objeto de tipo File con la ruta del archivo*/
    File archivoXLS = new File(rutaArchivo);
    /*Si el archivo existe se elimina*/
    if (archivoXLS.exists())
        archivoXLS.delete();//from   w w w.  j  a  v  a 2  s .com
    /*Se crea el archivo*/
    archivoXLS.createNewFile();

    /*Se crea el libro de excel usando el objeto de tipo Workbook*/
    Workbook libro = new HSSFWorkbook();
    CreationHelper createhelper = libro.getCreationHelper();
    CellStyle cellStyle = libro.createCellStyle();
    cellStyle.setDataFormat(createhelper.createDataFormat().getFormat("dd/mm/yyyy"));
    CellStyle cellStyle2 = libro.createCellStyle();

    /*Se inicializa el flujo de datos con el archivo xls*/
    FileOutputStream archivo = new FileOutputStream(archivoXLS);

    /*Utilizamos la clase Sheet para crear una nueva hoja de trabajo dentro del libro que creamos anteriormente*/
    Sheet hoja = libro.createSheet("ClientesPlacas");

    Font fuente = libro.createFont();
    fuente.setFontHeightInPoints((short) 13);
    fuente.setFontName("Arial");
    fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

    Font fuente2 = libro.createFont();
    fuente.setFontHeightInPoints((short) 13);
    fuente.setFontName("Arial");
    //fuente.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

    Row Enc = hoja.createRow(2);
    Cell celda = Enc.createCell(0);

    celda.setCellValue("PLACA DE VEHICULOS POR CLIENTES");

}

From source file:au.com.onegeek.lambda.parser.XslxUtil.java

License:Apache License

public static Object evaluateCellFormula(final Workbook workbook, final Cell cell) {
    FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
    CellValue cellValue = evaluator.evaluate(cell);
    Object result = null;/* ww w  . j  ava2 s  .c  om*/

    if (cellValue.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
        result = cellValue.getBooleanValue();
    } else if (cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC) {
        result = cellValue.getNumberValue();
    } else if (cellValue.getCellType() == Cell.CELL_TYPE_STRING) {
        result = cellValue.getStringValue();
    }

    return result;
}

From source file:bad.robot.excel.cell.HyperlinkCell.java

License:Apache License

private Hyperlink createHyperlink(Workbook workbook) {
    Hyperlink hyperlink = workbook.getCreationHelper().createHyperlink(LINK_URL);
    hyperlink.setAddress(link.toExternalForm());
    return hyperlink;
}

From source file:bad.robot.excel.matchers.StubCell.java

License:Apache License

static Cell createCell(int row, int column, Date date) {
    Workbook workbook = new HSSFWorkbook();
    Sheet sheet = workbook.createSheet();
    Cell cell = sheet.createRow(row).createCell(column, CELL_TYPE_NUMERIC);
    cell.setCellValue(date);//from w w w .ja v a2  s .co  m
    CellStyle style = workbook.createCellStyle();
    style.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat("m/d/yy h:mm"));
    cell.setCellStyle(style);
    return cell;
}

From source file:biz.webgate.dominoext.poi.component.kernel.simpleviewexport.WorkbooklExportProcessor.java

License:Apache License

public void process2HTTP(ExportModel expModel, UISimpleViewExport uis, HttpServletResponse hsr,
        DateTimeHelper dth) {//ww  w  .j  a  v a2s .c om
    try {
        String strFileName = uis.getDownloadFileName();

        Workbook wbCurrent = null;
        if (strFileName.toLowerCase().endsWith(".xlsx")) {
            wbCurrent = new XSSFWorkbook();
        } else {
            wbCurrent = new HSSFWorkbook();
        }
        HashMap<String, CellStyle> hsCS = new HashMap<String, CellStyle>();
        CreationHelper cr = wbCurrent.getCreationHelper();
        CellStyle csDate = wbCurrent.createCellStyle();
        csDate.setDataFormat(cr.createDataFormat().getFormat(dth.getDFDate().toPattern()));

        CellStyle csDateTime = wbCurrent.createCellStyle();
        csDateTime.setDataFormat(cr.createDataFormat().getFormat(dth.getDFDateTime().toPattern()));

        CellStyle csTime = wbCurrent.createCellStyle();
        csTime.setDataFormat(cr.createDataFormat().getFormat(dth.getDFTime().toPattern()));

        hsCS.put("DATE", csDate);
        hsCS.put("TIME", csTime);
        hsCS.put("DATETIME", csDateTime);

        Sheet sh = wbCurrent.createSheet("SVE Export");
        int nRowCount = 0;

        // BUILDING HEADER
        if (uis.isIncludeHeader()) {
            Row rw = sh.createRow(nRowCount);
            int nCol = 0;
            for (ExportColumn expColumn : expModel.getColumns()) {
                rw.createCell(nCol).setCellValue(expColumn.getColumnName());
                nCol++;
            }
            nRowCount++;
        }
        // Processing Values
        for (ExportDataRow expRow : expModel.getRows()) {
            Row rw = sh.createRow(nRowCount);
            int nCol = 0;
            for (ExportColumn expColumn : expModel.getColumns()) {
                Cell clCurrent = rw.createCell(nCol);
                setCellValue(expRow.getValue(expColumn.getPosition()), clCurrent, expColumn, hsCS);
                nCol++;
            }
            nRowCount++;
        }
        for (int nCol = 0; nCol < expModel.getColumns().size(); nCol++) {
            sh.autoSizeColumn(nCol);
        }
        if (strFileName.toLowerCase().endsWith(".xlsx")) {
            hsr.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        } else if (strFileName.toLowerCase().endsWith("xls")) {
            hsr.setContentType("application/vnd.ms-excel");

        } else {
            hsr.setContentType("application/octet-stream");
        }
        hsr.addHeader("Content-disposition", "inline; filename=\"" + strFileName + "\"");
        OutputStream os = hsr.getOutputStream();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        wbCurrent.write(bos);
        bos.writeTo(os);
        os.close();
    } catch (Exception e) {
        ErrorPageBuilder.getInstance().processError(hsr, "Error during SVE-Generation (Workbook Export)", e);
    }
}

From source file:blanco.commons.calc.parser.AbstractBlancoCalcParser.java

License:Open Source License

public static String getCellValue(Cell cell) {
    // 2016.01.20 j.amano
    // ?jxl to poi ?????
    //------------------------
    //??:\-1,000/*from w w  w .  j  av a 2  s  .  c o m*/
    //jxl:($1,000)?$?????????
    //poi:-1000
    //------------------------
    //??:2016/1/20
    //jxl:0020, 1 20, 2016
    //poi:2016/01/20 00:00:00
    //------------------------
    //??:#REF!???
    //jxl:#REF!
    //poi:#REF!
    //------------------------
    //??:1,000
    //jxl:" "1,000
    //poi:-1000
    //------------------------

    if (cell != null) {
        switch (cell.getCellType()) {
        case Cell.CELL_TYPE_BLANK:
            return "";
        case Cell.CELL_TYPE_STRING:
            return cell.getRichStringCellValue().getString();
        case Cell.CELL_TYPE_BOOLEAN:
            return String.valueOf(cell.getBooleanCellValue());
        case Cell.CELL_TYPE_NUMERIC:
            // ??
            if (DateUtil.isCellDateFormatted(cell)) {
                // ????
                Date dt = cell.getDateCellValue();
                // ????
                DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                String sDate = df.format(dt);
                return sDate;
            }
            // ???.0
            DecimalFormat format = new DecimalFormat("0.#");
            return format.format(cell.getNumericCellValue());
        case Cell.CELL_TYPE_FORMULA:
            Workbook wb = cell.getSheet().getWorkbook();
            CreationHelper crateHelper = wb.getCreationHelper();
            FormulaEvaluator evaluator = crateHelper.createFormulaEvaluator();
            return getCellValue(evaluator.evaluateInCell(cell));
        case Cell.CELL_TYPE_ERROR:
            byte errorCode = cell.getErrorCellValue();
            FormulaError error = FormulaError.forInt(errorCode);
            String errorText = error.getString();
            return errorText;
        default:
            return "";
        }
    }
    return "";
}

From source file:bloodbank.Simulation.java

/**
 *
 * @param args/*from w  w  w  .  j  a v  a 2  s.co m*/
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    //from 8am to 20pm 
    Random rng = new Random();

    Distribution plasmaInter = new DiscreteUniformDistribution(6, 6, rng);
    Distribution[] wholeInter = new Distribution[24];
    Distribution[] procedures = new Distribution[10];
    constructDistribution(wholeInter, procedures, rng);

    Simulation sim = new Simulation(plasmaInter, wholeInter, procedures);
    // Create the sheet
    Workbook wb = new HSSFWorkbook();
    CreationHelper createHelper = wb.getCreationHelper();
    Sheet sheet = wb.createSheet("new sheet");

    int runs = 1;
    Row row = sheet.createRow((short) 0);
    Cell cell = row.createCell(0);
    cell.setCellValue(createHelper.createRichTextString("Total running time"));
    cell = row.createCell(1);
    cell.setCellValue(createHelper.createRichTextString("P pre-donation sojourn time"));
    cell = row.createCell(2);
    cell.setCellValue(createHelper.createRichTextString("W pre-donation sojourn time"));
    cell = row.createCell(3);
    cell.setCellValue(createHelper.createRichTextString("P total sojourn time"));
    cell = row.createCell(4);
    cell.setCellValue(createHelper.createRichTextString("W total sojourn time"));
    cell = row.createCell(5);
    cell.setCellValue(createHelper.createRichTextString("Qmean # P&W at registration"));
    cell = row.createCell(6);
    cell.setCellValue(createHelper.createRichTextString("Qmean # P&W at questionnaire"));
    cell = row.createCell(7);
    cell.setCellValue(createHelper.createRichTextString("Qmean # P at (pre-)interview"));
    cell = row.createCell(8);
    cell.setCellValue(createHelper.createRichTextString("Qmean # W at (pre-)interview"));
    cell = row.createCell(9);
    cell.setCellValue(createHelper.createRichTextString("# of available doctors"));

    cell = row.createCell(10);
    cell.setCellValue(createHelper.createRichTextString("Qmean # P at pre-donation room"));
    cell = row.createCell(11);
    cell.setCellValue(createHelper.createRichTextString("Qmean # W at pre-donation room"));
    cell = row.createCell(12);
    cell.setCellValue(createHelper.createRichTextString("Qmean # P at donation room"));
    cell = row.createCell(13);
    cell.setCellValue(createHelper.createRichTextString("Qmean # W at donation room"));

    for (int i = 0; i < 16; i++) {
        /*cell=row.createCell(13+i);cell.setCellValue(createHelper.createRichTextString("BedOcc.Pl " + "hr " + (8 + i)));//donor room Plasma
        cell=row.createCell(13+1*16+i);cell.setCellValue(createHelper.createRichTextString("BedOcc.Wh " + "hr" + (8 + i)));//donor room Whole
        cell=row.createCell(13+2*16+i);cell.setCellValue(createHelper.createRichTextString("Queue0" + "hr" + (8 + i)));//Queue lenght reception
        cell=row.createCell(13+3*16+i);cell.setCellValue(createHelper.createRichTextString("QueueDocPl" + "hr" + (8 + i)));//Queue length doctor plasma
        cell=row.createCell(13+4*16+i);cell.setCellValue(createHelper.createRichTextString("QueueDocWh" + "hr" + (8 + i)));//Queue length doctor whole
        cell=row.createCell(13+5*16+i);cell.setCellValue(createHelper.createRichTextString("SJT Pl PreDon" + "hr" + (8 + i)));
        cell=row.createCell(13+6*16+i);cell.setCellValue(createHelper.createRichTextString("SJT Pl TotDon" + "hr" + (8 + i)));
        cell=row.createCell(13+7*16+i);cell.setCellValue(createHelper.createRichTextString("SJT Wh PreDon" + "hr" + (8 + i)));
        cell=row.createCell(13+8*16+i);cell.setCellValue(createHelper.createRichTextString("SJT Wh TotDon" + "hr" + (8 + i)));
        cell=row.createCell(13+9*16+i);cell.setCellValue(createHelper.createRichTextString("QueuePreDonPl" + "hr" + (8 + i)));
        cell=row.createCell(13+10*16+i);cell.setCellValue(createHelper.createRichTextString("QueuePreDonWh" + "hr" + (8 + i)));   
        cell=row.createCell(13+11*16+i);cell.setCellValue(createHelper.createRichTextString("QuestionNaire" + "hr" + (8 + i))); */
        cell = row.createCell(13 + 1 * 16 + i);
        cell.setCellValue(createHelper.createRichTextString("AvailableNurse" + "hr" + (8 + i)));
        cell = row.createCell(13 + 2 * 16 + i);
        cell.setCellValue(createHelper.createRichTextString("P Wait for connect" + "hr" + (8 + i)));
        cell = row.createCell(13 + 3 * 16 + i);
        cell.setCellValue(createHelper.createRichTextString("W Wait for connect" + "hr" + (8 + i)));
        cell = row.createCell(13 + 4 * 16 + i);
        cell.setCellValue(createHelper.createRichTextString("Wait for disconnect" + "hr" + (8 + i)));
    }

    //other measures can be added, see all measures in line 364-379, as well as variance  
    while (runs <= 10000) {//runs=10000 costs 9 seconds
        sim.simulate(sheet, runs);
        runs++;
    }
    FileOutputStream fileOut = new FileOutputStream("correct.xls");//name of the excel file
    wb.write(fileOut);
    fileOut.close();
}

From source file:bouttime.fileinput.ExcelFileInputTest.java

License:Open Source License

@BeforeClass
public static void setUpClass() throws Exception {
    // Create the input file
    inputFile = new File(INPUT_FILENAME);
    assertNotNull(inputFile);//from  w ww. ja v a 2s.c o m
    assertTrue(inputFile.createNewFile());
    Workbook wb = new XSSFWorkbook();
    CreationHelper createHelper = wb.getCreationHelper();
    Sheet s = wb.createSheet();

    makeWrestler(s, 0, "David", "Robinson", "Open", "5", "88", "88", "Spurs", "A", "50", "SW");
    makeWrestler(s, 1, "Tim", "Duncan", "Open", "4", "99", "99", "Spurs", "A", "21", "SW");
    makeWrestler(s, 2, "Tony", "Parker", "Rookie", "1", "77", "77", "Spurs", "B", "6", "SW");
    makeWrestler(s, 3, "Manu", "Ginobili", "Rookie", "3", "82", "80", "Spurs", "B", "12", "SW");
    makeWrestler(s, 4, "David", "Robinson", "Open", "5", "88", "88", "Spurs", "A", "50", "SW");

    FileOutputStream outputStream = new FileOutputStream(inputFile);
    wb.write(outputStream);
    outputStream.close();
}