Example usage for org.apache.poi.xssf.usermodel XSSFSheet createRow

List of usage examples for org.apache.poi.xssf.usermodel XSSFSheet createRow

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFSheet createRow.

Prototype

@Override
public XSSFRow createRow(int rownum) 

Source Link

Document

Create a new row within the sheet and return the high level representation Note: If a row already exists at this position, it is removed/overwritten and any existing cell is removed!

Usage

From source file:org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter.java

License:Open Source License

private <T extends Number> void writeTable(XSSFSheet sheet, List<List<T>> tmp, String title,
        List<String> headers, List<String> values, boolean isContinuous) {
    writeTableHeaders(sheet, title, headers);

    ArrayList<String> rowHeaders = Lists.newArrayList(values);
    if (!isContinuous)
        rowHeaders.add("Total");

    int counter = 0;
    int rownum = 4;

    for (String k : rowHeaders) {
        int cellnum = 0;
        XSSFRow row = sheet.createRow(rownum++);
        XSSFCell cell = row.createCell(cellnum++);
        cell.setCellValue(k);//  w w  w .  java 2s .  co  m
        cell.setCellStyle(headerStyle);

        for (T obj : tmp.get(counter)) {
            cell = row.createCell(cellnum++);
            cell.setCellStyle(tableStyle);

            if (obj instanceof Integer)
                cell.setCellValue((Integer) obj);
            else if (obj instanceof Float)
                cell.setCellValue((Float) obj);
            else
                cell.setCellValue(String.valueOf(obj));
        }

        counter++;
    }

    sheet.autoSizeColumn(0);
}

From source file:org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter.java

License:Open Source License

private void writeTableHeaders(XSSFSheet sheet, String title, List<String> headers) {
    int colNum = headers.size() + 1;

    IntStream.rangeClosed(0, 3).forEach(i -> {
        Row rowTemp = sheet.createRow(i);
        IntStream.rangeClosed(0, colNum).forEach(j -> rowTemp.createCell(j));
    });//from ww  w. j a  va2s.c  o  m

    Row row = sheet.getRow(0);
    Cell titleLabel = row.getCell(0);
    titleLabel.setCellValue(title);
    titleLabel.setCellStyle(titleStyle);
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, colNum));

    row = sheet.getRow(2);
    Cell crossVarLabel = row.getCell(0);
    crossVarLabel.setCellValue(this.crossVariable.getName());
    sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 0));

    Cell varLabel = row.getCell(1);
    varLabel.setCellValue(this.variable.getName());
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 1, colNum - 1));

    Cell totalLabel = row.getCell(colNum);
    totalLabel.setCellValue("Total");
    sheet.addMergedRegion(new CellRangeAddress(2, 3, colNum, colNum));

    int cellnum = 1;
    row = sheet.getRow(3);

    for (String h : headers) {
        Cell cell = row.getCell(cellnum++);
        cell.setCellValue(h);
    }

    addMergedStyles(sheet, new CellRangeAddress(2, 3, 0, colNum));
}

From source file:org.ohdsi.jCdmBuilder.EtlReport.java

License:Apache License

private void addRow(XSSFSheet sheet, Object... values) {
    Row row = sheet.createRow(sheet.getPhysicalNumberOfRows());
    for (Object value : values) {
        Cell cell = row.createCell(row.getPhysicalNumberOfCells());

        if (value instanceof Integer && value instanceof Long && value instanceof Double)
            cell.setCellValue(Double.valueOf(value.toString()));
        else/*from w w w .  j a  v a  2s  .  c om*/
            cell.setCellValue(value.toString());

    }
}

From source file:org.openbase.bco.ontology.lib.testing.Measurement.java

License:Open Source License

private void saveMemoryTestValues(final String sheetName, final List<Long> simpleQuMeasuredValues,
        final List<Long> complexQuMeasuredValues, final DataVolume dataVolume) {
    XSSFWorkbook workbook;//from   w  w w.  j  a va 2s.  co m
    XSSFSheet sheet;
    Row rowSimple;
    Row rowComplex;

    try {
        FileInputStream excelFile = new FileInputStream(new File(FILE_NAME));
        workbook = new XSSFWorkbook(excelFile);
        sheet = workbook.getSheet(sheetName);
        rowSimple = sheet.getRow(1);
        rowComplex = sheet.getRow(2);
    } catch (IOException ex) {
        workbook = new XSSFWorkbook();
        sheet = workbook.createSheet(sheetName);
        final Row row = sheet.createRow(0);
        rowSimple = sheet.createRow(1);
        rowComplex = sheet.createRow(2);

        row.createCell(1).setCellValue("ConfigData only");
        row.createCell(2).setCellValue("ConfigData and dayData");
        row.createCell(3).setCellValue("ConfigData and 4x dayData");
    }

    long sumSimple = 0L;
    long sumComplex = 0L;

    for (final long valueSimple : simpleQuMeasuredValues) {
        sumSimple += valueSimple;
    }
    for (final long valueComplex : complexQuMeasuredValues) {
        sumComplex += valueComplex;
    }

    int column = 0;

    switch (dataVolume) {
    case CONFIG:
        column = 1;
        break;
    case CONFIG_DAY:
        column = 2;
        break;
    case CONFIG_WEEK:
        column = 3;
        break;
    default:
        break;
    }

    System.out.println("Save date in column: " + column);

    // mean of simple trigger time
    final Cell cellMeanSimple = rowSimple.createCell(column);
    cellMeanSimple.setCellValue(sumSimple / simpleQuMeasuredValues.size());

    // mean of complex trigger time
    final Cell cellMeanComplex = rowComplex.createCell(column);
    cellMeanComplex.setCellValue(sumComplex / complexQuMeasuredValues.size());

    try {
        final File file = new File(FILE_NAME);
        file.setReadable(true, false);
        file.setExecutable(true, false);
        file.setWritable(true, false);
        System.out.println("Save data row ...");
        final FileOutputStream outputStream = new FileOutputStream(file);
        workbook.write(outputStream);
        workbook.close();
    } catch (IOException ex) {
        ExceptionPrinter.printHistory(ex, LOGGER);
    }
}

From source file:org.openbase.bco.ontology.lib.testing.Measurement.java

License:Open Source License

private void putIntoExcelFile(final String sheetName, final List<Long> simpleQuMeasuredValues,
        final List<Long> complexQuMeasuredValues, int daysCurCount) {
    // https://www.mkyong.com/java/apache-poi-reading-and-writing-excel-file-in-java/
    XSSFWorkbook workbook;/*from w w  w  .ja  v a  2s.  c  o  m*/
    XSSFSheet sheet;
    Row row;

    try {
        FileInputStream excelFile = new FileInputStream(new File(FILE_NAME));
        workbook = new XSSFWorkbook(excelFile);
        sheet = workbook.getSheet(sheetName);
    } catch (IOException ex) {
        workbook = new XSSFWorkbook();
        sheet = workbook.createSheet(sheetName);
        row = sheet.createRow(daysCurCount);

        row.createCell(0).setCellValue("Days");
        row.createCell(1).setCellValue("Triple");
        row.createCell(2).setCellValue("Mean of simple trigger");
        row.createCell(3).setCellValue("Mean of complex trigger");
    }

    row = sheet.createRow(daysCurCount + 1);

    System.out.println("simple: " + simpleQuMeasuredValues);
    System.out.println("simple count: " + simpleQuMeasuredValues.size());
    System.out.println("complex: " + complexQuMeasuredValues);
    System.out.println("complex count: " + complexQuMeasuredValues.size());

    long sumSimple = 0L;
    long sumComplex = 0L;

    for (final long valueSimple : simpleQuMeasuredValues) {
        sumSimple += valueSimple;
    }
    for (final long valueComplex : complexQuMeasuredValues) {
        sumComplex += valueComplex;
    }

    // number of days
    final Cell cellDay = row.createCell(0);
    cellDay.setCellValue(daysCurCount + 1);

    // number of triple
    final Cell cellTriple = row.createCell(1);
    cellTriple.setCellValue(numberOfTriple);

    // mean of simple trigger time
    final Cell cellMeanSimple = row.createCell(2);
    cellMeanSimple.setCellValue(sumSimple / simpleQuMeasuredValues.size());

    // mean of complex trigger time
    final Cell cellMeanComplex = row.createCell(3);
    cellMeanComplex.setCellValue(sumComplex / complexQuMeasuredValues.size());

    try {
        final File file = new File(FILE_NAME);
        file.setReadable(true, false);
        file.setExecutable(true, false);
        file.setWritable(true, false);
        System.out.println("Save data row ...");
        final FileOutputStream outputStream = new FileOutputStream(file);
        workbook.write(outputStream);
        workbook.close();
    } catch (IOException ex) {
        ExceptionPrinter.printHistory(ex, LOGGER);
    }
}

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

License:Open Source License

/**
 * Creates and returns a workbook that gets converted to an Excel file; each
 * row in the workbook shows fields from some part of a sample and analytes
 * and values//from w w  w.  j av a2s  .  c  o  m
 * 
 * @param results
 *        the list of VOs containing result info to be shown
 * @param auxiliary
 *        the list of VOs containing aux data info to be shown
 * @param noResAux
 *        the list of VOs containing info to be shown when both results and
 *        aux data are excluded
 * @param testAnaResMap
 *        the map containing result analytes and values selected by the
 *        user; if an analyte or value is not in the map, the result is not
 *        shown
 * @param auxFieldValMap
 *        the map containing aux data analytes and values selected by the
 *        user; if an analyte or value is not in the map, the aux data is
 *        not shown
 * @param moduleName
 *        the name of a security module for the logged in user; the module's
 *        clause is used to restrict the fetched data to specific records
 *        e.g. organizations
 * @param showReportableColumnsOnly
 *        if true, only reportable column analytes are shown
 * @param headers
 *        the list of labels for the column headers
 * @param data
 *        the VO containing the user's choices for the data shown e.g. the
 *        meta keys for selected columns and "include" and "exclude" flags
 * @param smMap
 *        the map that provides the data for the columns belonging to
 *        various parts of a sample e.g. domain, organization, project etc.
 * @param status
 *        the percent completion in this ReportStatus is updated every time
 *        a new row is added to the workbook
 */
private XSSFWorkbook getWorkbook(List<DataViewResultVO> results, List<DataViewResultVO> auxiliary,
        List<DataViewResultVO> noResAux, HashMap<Integer, HashSet<String>> testAnaResMap,
        HashMap<Integer, HashSet<String>> auxFieldValMap, String moduleName, boolean showReportableColumnsOnly,
        ArrayList<String> headers, DataView1VO data, HashMap<Integer, SampleManager1> smMap,
        ReportStatus status) throws Exception {
    boolean excludeOverride, excludeRes, excludeAux, samOverridden, anaOverridden, addRow;
    int i, j, resIndex, auxIndex, noResAuxIndex, rowIndex, numRes, numAux, numNoResAux, lastCol, currCol;
    Integer samId, prevSamId, resAccNum, auxAccNum, itemId, anaId, prevAnaId, anaIndex;
    String value;
    SampleManager1 sm;
    XSSFWorkbook wb;
    XSSFSheet sheet;
    DataViewResultVO res;
    ResultViewDO rowRes, colRes;
    Row currRow, prevRow;
    RowData rd;
    Cell cell;
    ArrayList<Integer> maxChars;
    ArrayList<ResultViewDO> smResults;
    HashMap<String, Integer> colAnaMap;
    HashMap<Integer, HashSet<String>> anaValMap;

    numRes = results == null ? 0 : results.size();
    numAux = auxiliary == null ? 0 : auxiliary.size();
    numNoResAux = noResAux == null ? 0 : noResAux.size();
    excludeOverride = "Y".equals(data.getExcludeResultOverride());
    excludeRes = "Y".equals(data.getExcludeResults());
    excludeAux = "Y".equals(data.getExcludeAuxData());

    resIndex = 0;
    auxIndex = 0;
    noResAuxIndex = 0;
    lastCol = 0;
    currCol = 0;
    rowIndex = 1;
    prevSamId = null;
    prevAnaId = null;
    anaIndex = null;
    samOverridden = false;
    anaOverridden = false;
    currRow = null;
    prevRow = null;
    sm = null;
    wb = new XSSFWorkbook();
    sheet = wb.createSheet();
    colAnaMap = new HashMap<String, Integer>();
    maxChars = new ArrayList<Integer>();
    rd = new RowData();

    status.setMessage(Messages.get().report_genDataView());
    status.setPercentComplete(0);
    session.setAttribute("DataViewReportStatus", status);

    /*
     * the lists of results and aux data are iterated through until there
     * are no more elements left in each of them to read from
     */
    while (resIndex < numRes || auxIndex < numAux || noResAuxIndex < numNoResAux) {
        /*
         * the user wants to stop the report
         */
        if (ReportStatus.Status.CANCEL.equals(status.getStatus())) {
            status.setMessage(Messages.get().report_stopped());
            return null;
        }

        status.setPercentComplete(
                100 * (resIndex + auxIndex + noResAuxIndex) / (numRes + numAux + numNoResAux));
        res = null;
        anaValMap = null;
        value = null;
        if (excludeRes && excludeAux) {
            res = noResAux.get(noResAuxIndex++);
        } else {
            if (resIndex < numRes && auxIndex < numAux) {
                resAccNum = results.get(resIndex).getSampleAccessionNumber();
                auxAccNum = auxiliary.get(auxIndex).getSampleAccessionNumber();
                /*
                 * if this result's accession number is less than or equal
                 * to this aux data's, add a row for this result, otherwise
                 * add a row for the aux data; this makes sure that the
                 * results for a sample are shown before the aux data;
                 * accession numbers are compared instead of sample ids
                 * because the former is the field shown in the report and
                 * not the latter
                 */
                if (resAccNum <= auxAccNum) {
                    res = results.get(resIndex++);
                    anaValMap = testAnaResMap;
                } else {
                    res = auxiliary.get(auxIndex++);
                    anaValMap = auxFieldValMap;
                }
            } else if (resIndex < numRes) {
                /*
                 * no more aux data left to show
                 */
                res = results.get(resIndex++);
                anaValMap = testAnaResMap;
            } else if (auxIndex < numAux) {
                /*
                 * no more results left to show
                 */
                res = auxiliary.get(auxIndex++);
                anaValMap = auxFieldValMap;
            }
        }

        samId = res.getSampleId();
        itemId = res.getSampleItemId();
        anaId = res.getAnalysisId();

        if (!samId.equals(prevSamId)) {
            /*
             * don't show any data for this sample if it's overridden and
             * such samples are excluded; whether the sample is overridden
             * is checked even if such samples are not excluded because
             * overridden result values are not shown in the report
             */
            sm = smMap.get(samId);
            samOverridden = false;
            if ((getSampleQAs(sm) != null)) {
                for (SampleQaEventViewDO sqa : getSampleQAs(sm)) {
                    if (Constants.dictionary().QAEVENT_OVERRIDE.equals(sqa.getTypeId())) {
                        samOverridden = true;
                        if (excludeOverride)
                            prevSamId = samId;
                        break;
                    }
                }
            }
        }

        if (samOverridden && excludeOverride) {
            prevSamId = samId;
            continue;
        }

        /*
         * don't show any data for this analysis if it's overridden and such
         * analyses are excluded; whether the analysis is overridden is
         * checked even if such analyses are not excluded because overridden
         * values are not shown in the report
         */
        if (anaId != null) {
            if (!anaId.equals(prevAnaId)) {
                anaOverridden = false;
                if ((getAnalysisQAs(sm) != null)) {
                    for (AnalysisQaEventViewDO aqa : getAnalysisQAs(sm)) {
                        if (aqa.getAnalysisId().equals(anaId)
                                && Constants.dictionary().QAEVENT_OVERRIDE.equals(aqa.getTypeId())) {
                            anaOverridden = true;
                            if (excludeOverride)
                                break;
                        }
                    }
                }
            }
            if (anaOverridden && excludeOverride) {
                prevSamId = samId;
                prevAnaId = anaId;
                continue;
            }
        }

        if (anaValMap != null) {
            /*
             * show this result or aux data only if its value was selected
             * by the user
             */
            value = getValue(anaValMap, res.getAnalyteId(), res.getValue(), res.getTypeId());
            if (value == null) {
                prevSamId = samId;
                prevAnaId = anaId;
                continue;
            }
        }

        currRow = sheet.createRow(rowIndex++);

        /*
         * fill the passed row's cells for all columns except the ones for
         * analytes and values
         */
        setBaseCells(sm, itemId, anaId, rd, data.getColumns(), moduleName != null, wb, currRow, maxChars);

        if (value != null) {
            /*
             * this row is for either a result or aux data; show the analyte
             */
            cell = currRow.createCell(currRow.getPhysicalNumberOfCells());
            setCellValue(cell, res.getAnalyteName(), null);
            setMaxChars(cell.getColumnIndex(), res.getAnalyteName(), maxChars, null);
            cell = currRow.createCell(currRow.getPhysicalNumberOfCells());
            if (anaId != null && !excludeRes) {
                /*
                 * this row is for a result; show the value only if the
                 * analysis and sample are not overridden
                 */
                if (!anaOverridden && !samOverridden)
                    setCellValue(cell, value, null);
                setMaxChars(cell.getColumnIndex(), cell.getStringCellValue(), maxChars, null);

                /*
                 * if this analyte has column analytes, show them in the
                 * header and their values in the columns; results for a
                 * sample can be null if it has no results with values but
                 * has aux data with values and aux data is not excluded
                 */
                smResults = getResults(sm);
                if (smResults != null) {
                    for (i = 0; i < smResults.size(); i++) {
                        rowRes = smResults.get(i);
                        if (!res.getId().equals(rowRes.getId()))
                            continue;
                        j = i + 1;
                        if (j < smResults.size() && "Y".equals(smResults.get(j).getIsColumn())) {
                            /*
                             * this analyte has column analytes; "lastCol"
                             * is the right-most column in the workbook; if
                             * an analyte doesn't have a column yet, that
                             * column will be added after "lastCol";
                             * "currCol" keeps track of the current column
                             */
                            if (lastCol == 0)
                                lastCol = currRow.getPhysicalNumberOfCells();

                            currCol = currRow.getPhysicalNumberOfCells();
                            while (j < smResults.size()) {
                                colRes = smResults.get(j++);
                                if ("N".equals(colRes.getIsColumn()))
                                    break;
                                if (showReportableColumnsOnly && "N".equals(colRes.getIsReportable()))
                                    continue;
                                anaIndex = colAnaMap.get(colRes.getAnalyte());

                                /*
                                 * if this column analyte's name is not
                                 * found in the map, create a new column and
                                 * start adding values in it; set the value
                                 * in this cell if the analyte is shown in
                                 * this column; if the analyte is not shown
                                 * in this column, find the column in which
                                 * it is shown and set the value
                                 */
                                if (anaIndex == null) {
                                    anaIndex = lastCol++;
                                    colAnaMap.put(colRes.getAnalyte(), anaIndex);
                                    headers.add(colRes.getAnalyte());
                                    setMaxChars(cell.getColumnIndex(), colRes.getAnalyte(), maxChars, null);
                                    cell = currRow.createCell(anaIndex);
                                } else if (anaIndex == currCol) {
                                    cell = currRow.createCell(currCol++);
                                } else {
                                    cell = currRow.createCell(anaIndex);
                                }

                                /*
                                 * set the value if the analysis and sample
                                 * are not overridden
                                 */
                                if (!anaOverridden && !samOverridden)
                                    setCellValue(cell, getValue(colRes.getValue(), colRes.getTypeId()), null);
                                setMaxChars(cell.getColumnIndex(), cell.getStringCellValue(), maxChars, null);
                            }
                        }
                    }
                }
            } else {
                /*
                 * this row is for an aux data; show the value
                 */
                setCellValue(cell, value, null);
                setMaxChars(cell.getColumnIndex(), value, maxChars, null);
            }
        }

        prevAnaId = anaId;
        prevSamId = samId;

        /*
         * an empty row can't be created and then added to the sheet, it has
         * to be obtained from the sheet; thus it has to be removed if it
         * shouldn't be shown because it has the same data as the previous
         * row in all cells; this can happen if e.g. a user selects only
         * container and sample type but all sample items in a sample have
         * the same values for these fields
         */
        if (isSameDataInRows(currRow, prevRow)) {
            sheet.removeRow(currRow);
            rowIndex--;
        } else {
            prevRow = currRow;
        }
    }

    /*
     * add the header row and set the header labels for all columns
     */
    setHeaderCells(sheet, wb, headers, maxChars);

    /*
     * 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);

    return wb;
}

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

License:Open Source License

private void fillLoggedInSheet(XSSFWorkbook wb, ArrayList<AnalysisViewVO> list, boolean mySection) {
    int r;/*from w  ww  . j  ava2s  .  c o  m*/
    SystemUserPermission perm;
    ModulePermission modPerm;
    XSSFSheet sheet;

    perm = userCache.getPermission();
    modPerm = perm.getModule("patient");
    if (modPerm == null)
        modPerm = new ModulePermission();

    sheet = wb.createSheet(Messages.get().todo_loggedIn());
    r = 0;

    addHeaderRow(sheet.createRow(r++), Messages.get().todo_accNum(), Messages.get().todo_priority(),
            Messages.get().todo_domain(), Messages.get().todo_section(), Messages.get().todo_test(),
            Messages.get().todo_method(), Messages.get().todo_collected(), Messages.get().todo_received(),
            Messages.get().todo_override(), Messages.get().todo_holding(), Messages.get().todo_expCompletion(),
            Messages.get().todo_domainSpecField(), Messages.get().todo_reportTo());

    for (AnalysisViewVO a : list) {
        /*
         * if this sample has patient info, the user must have the right
         * permission to see it; also, show this analysis only if
         * doesn't belong to a deactivated domain e.g. private well
         */
        if (mySection && perm.getSection(a.getSectionName()) == null || !canViewSample(a.getDomain(), modPerm)
                || domains.get(a.getDomain()) == null)
            continue;

        addDataRow(sheet.createRow(r++), a.getAccessionNumber(), a.getPriority(), domains.get(a.getDomain()),
                a.getSectionName(), a.getTestName(), a.getMethodName(),
                TurnaroundUtil.getCombinedYM(a.getCollectionDate(), a.getCollectionTime()), a.getReceivedDate(),
                a.getAnalysisResultOverride(),
                TurnaroundUtil.getPercentHoldingUsed(a.getStartedDate(), a.getCollectionDate(),
                        a.getCollectionTime(), a.getTimeHolding()),
                TurnaroundUtil.getPercentExpectedCompletion(a.getCollectionDate(), a.getCollectionTime(),
                        a.getReceivedDate(), a.getPriority(), a.getTimeTaAverage()),
                a.getToDoDescription(), a.getPrimaryOrganizationName());
    }

    setSize(sheet, 13);
}

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

License:Open Source License

private void fillInitiatedSheet(XSSFWorkbook wb, ArrayList<AnalysisViewVO> list, boolean mySection) {
    int r, initDays;
    SystemUserPermission perm;/* www  .j  av a2 s. c  om*/
    ModulePermission modPerm;
    XSSFSheet sheet;
    Datetime now;

    perm = userCache.getPermission();
    modPerm = perm.getModule("patient");
    if (modPerm == null)
        modPerm = new ModulePermission();
    now = Datetime.getInstance();
    sheet = wb.createSheet(Messages.get().todo_initiated());
    r = 0;

    addHeaderRow(sheet.createRow(r++), Messages.get().todo_accNum(), Messages.get().todo_priority(),
            Messages.get().todo_domain(), Messages.get().todo_section(), Messages.get().todo_test(),
            Messages.get().todo_method(), Messages.get().todo_holding(), Messages.get().todo_expCompletion(),
            Messages.get().todo_daysInInitiated(), Messages.get().todo_domainSpecField(),
            Messages.get().todo_reportTo());

    for (AnalysisViewVO a : list) {
        /*
         * if this sample has patient info, the user must have the right
         * permission to see it; also, show this analysis only if
         * doesn't belong to a deactivated domain e.g. private well
         */
        if (mySection && perm.getSection(a.getSectionName()) == null || !canViewSample(a.getDomain(), modPerm)
                || domains.get(a.getDomain()) == null)
            continue;

        initDays = 0;
        if (a.getStartedDate() != null)
            initDays = TurnaroundUtil.diffDays(a.getStartedDate(), now);

        addDataRow(sheet.createRow(r++), a.getAccessionNumber(), a.getPriority(), domains.get(a.getDomain()),
                a.getSectionName(), a.getTestName(), a.getMethodName(),
                TurnaroundUtil.getPercentHoldingUsed(a.getStartedDate(), a.getCollectionDate(),
                        a.getCollectionTime(), a.getTimeHolding()),
                TurnaroundUtil.getPercentExpectedCompletion(a.getCollectionDate(), a.getCollectionTime(),
                        a.getReceivedDate(), a.getPriority(), a.getTimeTaAverage()),
                initDays, a.getToDoDescription(), a.getPrimaryOrganizationName());
    }

    setSize(sheet, 11);
}

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

License:Open Source License

private void fillWorksheetSheet(XSSFWorkbook wb, ArrayList<ToDoWorksheetVO> list, boolean mySection) {
    int r;//from www .  jav  a 2s .  co  m
    SystemUserPermission perm;
    XSSFSheet sheet;

    perm = userCache.getPermission();

    sheet = wb.createSheet(Messages.get().todo_worksheet());
    r = 0;

    addHeaderRow(sheet.createRow(r++), Messages.get().todo_worksheetNum(), Messages.get().gen_username(),
            Messages.get().todo_section(), Messages.get().gen_description(), Messages.get().todo_created());

    for (ToDoWorksheetVO w : list) {
        if (mySection && perm.getSection(w.getSectionName()) == null)
            continue;

        addDataRow(sheet.createRow(r++), w.getId(), w.getSystemUserName(), w.getSectionName(),
                w.getDescription(), w.getCreatedDate());
    }

    setSize(sheet, 5);
}

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

License:Open Source License

private void fillCompletedSheet(XSSFWorkbook wb, ArrayList<AnalysisViewVO> list, boolean mySection) {
    int r;/* ww w  .  ja  v a  2 s.c o  m*/
    SystemUserPermission perm;
    ModulePermission modPerm;
    XSSFSheet sheet;

    perm = userCache.getPermission();
    modPerm = perm.getModule("patient");
    if (modPerm == null)
        modPerm = new ModulePermission();

    sheet = wb.createSheet(Messages.get().todo_completed());
    r = 0;

    addHeaderRow(sheet.createRow(r++), Messages.get().todo_accNum(), Messages.get().todo_priority(),
            Messages.get().todo_domain(), Messages.get().todo_section(), Messages.get().todo_test(),
            Messages.get().todo_method(), Messages.get().todo_override(), Messages.get().todo_completed(),
            Messages.get().todo_domainSpecField(), Messages.get().todo_reportTo());

    for (AnalysisViewVO a : list) {
        /*
         * if this sample has patient info, the user must have the right
         * permission to see it; also, show this analysis only if
         * doesn't belong to a deactivated domain e.g. private well
         */
        if (mySection && perm.getSection(a.getSectionName()) == null || !canViewSample(a.getDomain(), modPerm)
                || domains.get(a.getDomain()) == null)
            continue;

        addDataRow(sheet.createRow(r++), a.getAccessionNumber(), a.getPriority(), domains.get(a.getDomain()),
                a.getSectionName(), a.getTestName(), a.getMethodName(), a.getAnalysisResultOverride(),
                a.getCompletedDate(), a.getToDoDescription(), a.getPrimaryOrganizationName());
    }

    setSize(sheet, 10);
}