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

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

Introduction

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

Prototype

@Override
public HSSFRow getRow(int rowIndex) 

Source Link

Document

Returns the logical row (not physical) 0-based.

Usage

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

/**
 * Method that set the first sheet of the information
 * @param sheetDetails// w ww . j ava 2  s .c  om
 */
private void loadDetailSheet(HSSFSheet sheetDetails) {
    sheetDetails.getRow(3).getCell(1).setCellValue(property.getKey(NAME_COMPANY_SEQUENCE, Bundle.conf));
    sheetDetails.getRow(4).getCell(1)
            .setCellValue(shipment.getStShipmentSet().getStInvestigator().getInvest_name());
    //TODO
    //sheetDetails.getRow(5).getCell(1).setCellValue(shipment.getStShipmentSet().getStInvestigator().getInvest_email());
    //sheetDetails.getRow(6).getCell(1).setCellValue(shipment.getStShipmentSet().getStInvestigator().getInvest_phone());
    sheetDetails.getRow(7).getCell(1).setCellValue(shipment.getTrackingNumberDelivery());
    sheetDetails.getRow(8).getCell(1).setCellValue(shipment.getTrackingNumberLocal());
    sheetDetails.getRow(9).getCell(1).setCellValue(userBean.getCorp());
    sheetDetails.getRow(10).getCell(1).setCellValue("");
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private void loadListGenotypingSewrvices() {
    int size = setShipmentDetail.iterator().next().getStSampleDetail().getLabstudyid().getPlatesize();
    HSSFSheet sheetgrid = listBook.getSheetAt(5);
    HSSFCell cellStyle = sheetgrid.getRow(11).getCell(0);
    HSSFCellStyle style = cellStyle.getCellStyle();
    HSSFCell cellStyleIntertek = sheetgrid.getRow(19).getCell(11);
    HSSFCellStyle styleIntertek = cellStyleIntertek.getCellStyle();
    if (size == SIZE_PLATE_96) {
        rowsplate = 8;/*from   w  ww .  j  a v a 2 s  . co  m*/
        colsplate = 12;
    } else {
        rowsplate = 16;
        colsplate = 24;
    }

    LinkedHashMap<String, Map<String, SampleDetail>> mapPlates = new LinkedHashMap<String, Map<String, SampleDetail>>();
    for (ShipmentDetail shipmentDetail : setShipmentDetail) {

        SampleDetail detail = shipmentDetail.getStSampleDetail();
        if (mapPlates.containsKey(detail.getPlatename())) {
            Map<String, SampleDetail> map = mapPlates.get(detail.getPlatename());
            String letter = detail.getPlateloc().substring(0, 1);
            String number = detail.getPlateloc().substring(1, detail.getPlateloc().length());
            map.put(getEquivalenceInInteger(letter) + "|" + number, detail);
        } else {
            Map<String, SampleDetail> map = new HashMap<String, SampleDetail>();
            String letter = detail.getPlateloc().substring(0, 1);
            String number = detail.getPlateloc().substring(1, detail.getPlateloc().length());
            map.put(getEquivalenceInInteger(letter) + "|" + number, detail);
            mapPlates.put(detail.getPlatename(), map);
        }
    }

    Iterator<Entry<String, Map<String, SampleDetail>>> it = mapPlates.entrySet().iterator();
    int row = 10;
    int column = 0;
    while (it.hasNext()) {
        Map.Entry<String, Map<String, SampleDetail>> entry = (Entry<String, Map<String, SampleDetail>>) it
                .next();
        if (entry.getKey() != null) {
            Map<String, SampleDetail> map = entry.getValue();
            validateRow(sheetgrid, row);
            HSSFCell cellPlateName = validateCell(sheetgrid, row, 0);
            cellPlateName.setCellValue("Plate");
            cellPlateName.setCellStyle(style);
            HSSFCell cellPlate = validateCell(sheetgrid, row, 1);
            cellPlate.setCellValue(entry.getKey());
            row = row + 1;
            drawingFormatPlate(style, sheetgrid, row);
            for (int indexRow = 1; indexRow <= rowsplate; indexRow++) {
                for (int indexCol = 1; indexCol <= colsplate; indexCol++) {

                    SampleDetail detail = map.get(indexRow + "|" + indexCol);
                    validateRow(sheetgrid, row + indexRow);
                    HSSFCellStyle styleCell = null;
                    if (detail.getControltype() != null && !detail.getControltype().equals(""))
                        styleCell = validateStatusSample(detail.getControltype());
                    else {
                        styleCell = styleCellNormally;
                    }
                    if (sheetgrid.getRow(row + indexRow).getCell(column + indexCol) == null)
                        sheetgrid.getRow(row + indexRow).createCell(column + indexCol);
                    HSSFCell cell = sheetgrid.getRow(row + indexRow).getCell(column + indexCol);
                    if (detail.getSamplegid() == null
                            || (detail.getControltype() != null && !detail.getControltype().equals(""))) {
                        cell.setCellValue(mapBlank.get(detail.getStudysampleid()));
                        cell.setCellStyle(styleCell);
                    } else {
                        styleCell = styleCellNormally;
                        cell.setCellValue(detail.getLabstudyid().getPrefix()
                                + (detail.getLabstudyid().isUsePadded()
                                        ? StrUtils.getPaddingCeros(detail.getSamplegid())
                                        : String.valueOf(detail.getSamplegid()))
                                + "-" + detail.getStudysampleid());
                    }
                    detail.getPlateloc();
                    if (detail.getPlateloc().equals("H11") || detail.getPlateloc().equals("H12")) {
                        cell.setCellStyle(styleIntertek);
                    }
                }
            }
            row = row + rowsplate;
            row = row + 2;
        }

    }
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private void loadPlateID(HSSFSheet sheetList) {
    if (mapPlate != null && !mapPlate.isEmpty()) {
        Iterator<Map.Entry<Integer, String>> it = mapPlate.entrySet().iterator();
        int inidatsheetList = 12;
        int indexRow = 0;
        while (it.hasNext()) {
            HSSFRow actrowsheetList;//from  ww  w.  j av  a 2  s  .c o  m
            if (sheetList.getRow(indexRow + inidatsheetList) == null)
                sheetList.createRow(indexRow + inidatsheetList);
            actrowsheetList = sheetList.getRow(indexRow + inidatsheetList);
            if (actrowsheetList.getCell(1) == null)
                actrowsheetList.createCell(1);
            Map.Entry<Integer, String> pair = it.next();
            actrowsheetList.getCell(1).setCellValue(pair.getValue());
            indexRow++;
        }
    }
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private void loadListSampleIDGenotypingService(HSSFSheet sheetList) {
    int inidatsheetList = 15;
    String wellkbio;/*from   w  ww  .j  a v  a  2 s . c  o  m*/
    int i = 0;
    int indexBlank = 1;
    for (ShipmentDetail shipmentDetail : setShipmentDetail) {
        SampleDetail sampledet = shipmentDetail.getStSampleDetail();
        HSSFRow actrowsheetList;
        //****************    sheetList  **************************
        //
        if (sheetList.getRow(i + inidatsheetList) == null)
            sheetList.createRow(i + inidatsheetList);
        actrowsheetList = sheetList.getRow(i + inidatsheetList);
        if (actrowsheetList.getCell(1) == null)
            actrowsheetList.createCell(1);
        if (sampledet.getSamplegid() != null)
            actrowsheetList.getCell(1)
                    .setCellValue(sampledet.getLabstudyid().getPrefix()
                            + (sampledet.getLabstudyid().isUsePadded()
                                    ? StrUtils.getPaddingCeros(sampledet.getSamplegid())
                                    : String.valueOf(sampledet.getSamplegid()))
                            + "-" + sampledet.getStudysampleid());
        if (actrowsheetList.getCell(2) == null)
            actrowsheetList.createCell(2);
        actrowsheetList.getCell(2)
                .setCellValue(getPlate(sampledet.getPlatename(), sampledet.getLabstudyid().getPrefix()));
        if (actrowsheetList.getCell(3) == null)
            actrowsheetList.createCell(3);
        wellkbio = sampledet.getPlateloc();
        if (wellkbio.length() == 2)
            wellkbio = wellkbio.substring(0, 1) + "0" + wellkbio.substring(1);
        actrowsheetList.getCell(3).setCellValue(wellkbio);

        if (sampledet.getPlateloc().equals("H11") || sampledet.getPlateloc().equals("H12")) {
            actrowsheetList.getCell(1).setCellValue("");
        } else {
            //Por especificaciones de KBIo se pone C si es un control y nada si es ADN normal
            if (sampledet.getControltype() != null) {
                if (!sampledet.getControltype().equals("")) {
                    actrowsheetList.getCell(1)
                            .setCellValue(getPathEmpty(indexBlank, sampledet.getStudysampleid()));
                    indexBlank++;
                }
            } else if (sampledet.getSamplegid() == null) {
                actrowsheetList.getCell(1).setCellValue(getPathEmpty(indexBlank, sampledet.getStudysampleid()));
                indexBlank++;
            }

        }
        if (actrowsheetList.getCell(7) == null)
            actrowsheetList.createCell(7);
        actrowsheetList.getCell(7).setCellValue(
                sampledet.getBreedergid() != null ? String.valueOf(sampledet.getBreedergid()) : "");
        if (actrowsheetList.getCell(8) == null)
            actrowsheetList.createCell(8);
        actrowsheetList.getCell(8)
                .setCellValue(sampledet.getNplanta() != null ? String.valueOf(sampledet.getNplanta()) : "");
        i = i + 1;
    }
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

/**
 * Method that set the first sheet of the information
 * @param sheetDetails/*from   w  ww . j a  v  a  2  s . com*/
 */
private void loadCustomerDetailSheetGenotyping(HSSFSheet sheetDetails) {
    sheetDetails.getRow(13).getCell(2).setCellValue(property.getKey(NAME_COMPANY_SEQUENCE, Bundle.conf));
    sheetDetails.getRow(13).getCell(4)
            .setCellValue(shipment.getStShipmentSet().getStInvestigator().getInvest_name());
    sheetDetails.getRow(14).getCell(4).setCellValue(userBean.getResearcherEMail());
    sheetDetails.getRow(16).getCell(4).setCellValue(shipment.getComment());
    sheetDetails.getRow(18).getCell(2).setCellValue(userBean.getResearcherEMail() + ";"
            + property.getKey(Constants.REPORT_PATH_GENOTYPING_SERVICES_EMAIL_INTERTEK, Bundle.conf));
    sheetDetails.getRow(20).getCell(2)
            .setCellValue(userBean.getResearcherEMail() + ";" + Constants.EMAIL_ACCOUNT_RECEIVER_MAIZE
                    + property.getKey(Constants.REPORT_PATH_GENOTYPING_SERVICES_EMAIL_INTERTEK, Bundle.conf));
    sheetDetails.getRow(25).getCell(2).setCellValue(property.getKey(NAME_COMPANY_SEQUENCE, Bundle.conf));
    sheetDetails.getRow(25).getCell(4)
            .setCellValue(shipment.getStShipmentSet().getStInvestigator().getInvest_name());
    sheetDetails.getRow(37).getCell(2).setCellValue(shipment.getTrackingNumberLocal());
    sheetDetails.getRow(41).getCell(2).setCellValue(StrUtils.getCrop(userBean.getTypeCorp(), property));
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private HSSFCell validateCell(HSSFSheet sheetgrid, int indexRow, int indexCell) {
    if (sheetgrid.getRow(indexRow).getCell(indexCell) == null) {
        sheetgrid.getRow(indexRow).createCell(indexCell);
        return sheetgrid.getRow(indexRow).getCell(indexCell);
    } else {/*from www. ja  v  a  2  s  .c  o m*/
        return sheetgrid.getRow(indexRow).getCell(indexCell);
    }
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private void validateRow(HSSFSheet sheetgrid, int indexRow) {
    if (sheetgrid.getRow(indexRow) == null)
        sheetgrid.createRow(indexRow);//from w ww . jav  a2  s . c o  m
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private void loadListGridIntertek() {
    int size = setShipmentDetail.iterator().next().getStSampleDetail().getLabstudyid().getPlatesize();
    HSSFSheet sheetgrid = listBook.getSheetAt(4);
    HSSFCell cellStyle = sheetgrid.getRow(5).getCell(2);
    HSSFCellStyle style = cellStyle.getCellStyle();
    if (size == SIZE_PLATE_96) {
        rowsplate = 8;//  www. j  a  v a 2s.  co m
        colsplate = 12;
    } else {
        rowsplate = 16;
        colsplate = 24;
    }

    LinkedHashMap<String, Map<String, SampleDetail>> mapPlates = new LinkedHashMap<String, Map<String, SampleDetail>>();
    for (ShipmentDetail shipmentDetail : setShipmentDetail) {
        SampleDetail detail = shipmentDetail.getStSampleDetail();
        if (mapPlates.containsKey(detail.getPlatename())) {
            Map<String, SampleDetail> map = mapPlates.get(detail.getPlatename());
            String letter = detail.getPlateloc().substring(0, 1);
            String number = detail.getPlateloc().substring(1, detail.getPlateloc().length());
            map.put(getEquivalenceInInteger(letter) + "|" + number, detail);
        } else {
            Map<String, SampleDetail> map = new HashMap<String, SampleDetail>();
            String letter = detail.getPlateloc().substring(0, 1);
            String number = detail.getPlateloc().substring(1, detail.getPlateloc().length());
            map.put(getEquivalenceInInteger(letter) + "|" + number, detail);
            mapPlates.put(detail.getPlatename(), map);
        }
    }

    Iterator<Entry<String, Map<String, SampleDetail>>> it = mapPlates.entrySet().iterator();
    int row = 4;
    int column = 2;
    while (it.hasNext()) {
        Map.Entry<String, Map<String, SampleDetail>> entry = (Entry<String, Map<String, SampleDetail>>) it
                .next();
        if (entry.getKey() != null) {

            Map<String, SampleDetail> map = entry.getValue();
            validateRow(sheetgrid, row);
            HSSFCell cellPlate = validateCell(sheetgrid, row, 1);
            cellPlate.setCellValue(entry.getKey());
            row = row + 1;
            drawingFormatPlate(style, sheetgrid, row);
            for (int indexRow = 1; indexRow <= rowsplate; indexRow++) {
                for (int indexCol = 1; indexCol <= colsplate; indexCol++) {
                    SampleDetail detail = map.get(indexRow + "|" + indexCol);
                    validateRow(sheetgrid, row + indexRow);
                    HSSFCellStyle styleCell = null;
                    if (detail.getControltype() != null && !detail.getControltype().equals(""))
                        styleCell = validateStatusSample(detail.getControltype());
                    else {
                        styleCell = styleCellNormally;
                    }
                    if (sheetgrid.getRow(row + indexRow).getCell(column + indexCol) == null)
                        sheetgrid.getRow(row + indexRow).createCell(column + indexCol);
                    HSSFCell cell = sheetgrid.getRow(row + indexRow).getCell(column + indexCol);
                    if (detail.getSamplegid() == null
                            || (detail.getControltype() != null && !detail.getControltype().equals(""))) {
                        cell.setCellValue("BLANK");
                        cell.setCellStyle(styleCell);
                    } else {
                        styleCell = styleCellNormally;
                        cell.setCellValue(
                                detail.getLabstudyid().getPrefix() + (detail.getLabstudyid().isUsePadded()
                                        ? StrUtils.getPaddingCeros(detail.getSamplegid())
                                        : String.valueOf(detail.getSamplegid())));
                    }
                }
            }
            row = row + rowsplate;
            row = row + 2;
        }

    }
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private void loadListSampleID(HSSFSheet sheetList) {

    int inidatsheetList = 2;
    String wellkbio;/* w  ww  .  ja  v a 2s  .  com*/
    int mod = setShipmentDetail.iterator().next().getStSampleDetail().getLabstudyid().getPlatesize();
    int plates = setShipmentDetail.size() / mod;

    int i = 0;
    for (ShipmentDetail shipmentDetail : setShipmentDetail) {
        SampleDetail sampledet = shipmentDetail.getStSampleDetail();
        HSSFRow actrowsheetList;
        //****************    sheetList  **************************
        //
        if (sheetList.getRow(i + inidatsheetList) == null)
            sheetList.createRow(i + inidatsheetList);
        actrowsheetList = sheetList.getRow(i + inidatsheetList);
        if (actrowsheetList.getCell(0) == null)
            actrowsheetList.createCell(0);
        if (sampledet.getSamplegid() != null)
            actrowsheetList.getCell(0).setCellValue(
                    sampledet.getLabstudyid().getPrefix() + (sampledet.getLabstudyid().isUsePadded()
                            ? StrUtils.getPaddingCeros(sampledet.getSamplegid())
                            : String.valueOf(sampledet.getSamplegid())));
        if (actrowsheetList.getCell(1) == null)
            actrowsheetList.createCell(1);
        actrowsheetList.getCell(1).setCellValue(sampledet.getPlatename());
        if (actrowsheetList.getCell(2) == null)
            actrowsheetList.createCell(2);
        wellkbio = sampledet.getPlateloc();
        if (wellkbio.length() == 2)
            wellkbio = wellkbio.substring(0, 1) + "0" + wellkbio.substring(1);
        actrowsheetList.getCell(2).setCellValue(wellkbio);
        if (actrowsheetList.getCell(3) == null)
            actrowsheetList.createCell(3);
        actrowsheetList.getCell(3).setCellValue("");
        //Por especificaciones de KBIo se pone C si es un control y nada si es ADN normal
        if (sampledet.getControltype() != null)
            if (sampledet.getControltype().equals("K") || sampledet.getControltype().equals("B"))
                actrowsheetList.getCell(3).setCellValue("C");

        if (sampledet.getSamplegid() == null)
            actrowsheetList.getCell(3).setCellValue("C");

        if (actrowsheetList.getCell(4) == null)
            actrowsheetList.createCell(4);
        actrowsheetList.getCell(4).setCellValue(sampledet.getLabstudyid().getPlatesize());

        i = i + 1;
    }
}

From source file:com.cimmyt.reports.impl.ServiceReportKBioImpl.java

License:Apache License

private void loadOrderForm(HSSFSheet sheet) {
    sheet.getRow(3).getCell(4).setCellValue(property.getKey(NAME_COMPANY_SEQUENCE, Bundle.conf));
    sheet.getRow(6).getCell(4).setCellValue(userBean.getCorp());

}