Example usage for org.apache.poi.xssf.usermodel XSSFRow createCell

List of usage examples for org.apache.poi.xssf.usermodel XSSFRow createCell

Introduction

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

Prototype

@Override
public XSSFCell createCell(int columnIndex) 

Source Link

Document

Use this to create new cells within the row and return it.

Usage

From source file:control.GhiFile.java

public void taoDanhSachHoaDoa(ArrayList<HoaDonBanHang> dsHoaDon) {
    XSSFRow rowTitle = sheet.createRow(0);
    rowTitle.createCell(0).setCellValue("M ha n");
    rowTitle.createCell(1).setCellValue("Tng ti?n");
    rowTitle.createCell(2).setCellValue("Gim gi");
    rowTitle.createCell(3).setCellValue("Khch  tr");
    rowTitle.createCell(4).setCellValue("Th?i gian");
    rowTitle.createCell(5).setCellValue("Ghi ch");

    int rowNum = sheet.getLastRowNum();
    for (int i = 0; i < dsHoaDon.size(); i++) {
        rowNum++;//  w  w w  . j av a 2  s .c  om
        XSSFRow row = sheet.createRow(rowNum);
        HoaDonBanHang hd = dsHoaDon.get(i);

        row.createCell(0).setCellValue(hd.mMaHoaDonBanHang);
        row.createCell(1).setCellValue(hd.mTongTien);
        row.createCell(2).setCellValue(hd.mGiaGiam);
        row.createCell(3).setCellValue(hd.mKhachDaTra);
        row.createCell(4).setCellValue(hd.mThoiGian);
        row.createCell(5).setCellValue(hd.mGhiChu);

    }
    File myFile = new File(path());
    FileOutputStream os = null;
    try {

        // Khi to Stream  ghi file
        os = new FileOutputStream(myFile);

        //Ghi d liu t workbook vo 
        workbook.write(os);
        System.out.println("Vit d liu vo file excel thnh cng");

        //?ng workbook
        workbook.close();

        // ?ng stream
        os.close();

    } catch (FileNotFoundException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:control.GhiFile.java

public void taoFileHangNhap(ArrayList<HangHoa> arlHangNhap) {

    // ?t tn ct//from  w ww .  j ava2  s.c  o m
    XSSFRow rowTitle = sheet.createRow(0);
    rowTitle.createCell(0).setCellValue("M sn phm");
    rowTitle.createCell(1).setCellValue("Tn sn phm");
    rowTitle.createCell(2).setCellValue("Nhm sn phm");
    rowTitle.createCell(3).setCellValue("Gi mua");
    rowTitle.createCell(4).setCellValue("S lng");

    int rowNum = sheet.getLastRowNum();
    for (int i = 0; i < arlHangNhap.size(); i++) {
        rowNum++;
        XSSFRow row = sheet.createRow(rowNum);

        HangHoa hn = arlHangNhap.get(i);

        row.createCell(0).setCellValue(hn.mMaHangHoa);
        row.createCell(1).setCellValue(hn.mTenHangHoa);
        row.createCell(2).setCellValue(hn.mNhomHangHoa);
        row.createCell(3).setCellValue(hn.mGiaVon);
        row.createCell(4).setCellValue(3); // s lng cng
    }
    File myFile = new File(path());
    FileOutputStream os = null;
    try {

        // Khi to Stream  ghi file
        os = new FileOutputStream(myFile);

        //Ghi d liu t workbook vo 
        workbook.write(os);
        System.out.println("Vit d liu vo file excel thnh cng");

        //?ng workbook
        workbook.close();

        // ?ng stream
        os.close();

    } catch (FileNotFoundException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:control.GhiFile.java

public void taoFileNhaCungCap(ArrayList<NhaCungCap> dsNhaCungCap) {

    // ?t tn ct//from  w ww.  j a v  a  2 s  .  co m
    XSSFRow rowTitle = sheet.createRow(0);
    rowTitle.createCell(0).setCellValue("M nh cung cp");
    rowTitle.createCell(1).setCellValue("Tn nh cung cp");
    rowTitle.createCell(2).setCellValue("Nhm nh cung cp");
    rowTitle.createCell(3).setCellValue("Cn n");
    rowTitle.createCell(4).setCellValue("Email");
    rowTitle.createCell(4).setCellValue("?a ch");

    int rowNum = sheet.getLastRowNum();
    for (int i = 0; i < dsNhaCungCap.size(); i++) {
        rowNum++;
        XSSFRow row = sheet.createRow(rowNum);

        NhaCungCap ncc = dsNhaCungCap.get(i);

        row.createCell(0).setCellValue(ncc.mMaNhaCungCap);
        row.createCell(1).setCellValue(ncc.mTenNhaCungCap);
        row.createCell(2).setCellValue(ncc.mNhomNhaCungCap);
        // n hin ti
        row.createCell(3).setCellValue(ncc.mMaCongNoNhaCungCap);
        row.createCell(4).setCellValue(ncc.mEmail);
        row.createCell(5).setCellValue(ncc.mDiaChi);
    }
    File myFile = new File(path());
    FileOutputStream os = null;
    try {

        // Khi to Stream  ghi file
        os = new FileOutputStream(myFile);

        //Ghi d liu t workbook vo 
        workbook.write(os);
        System.out.println("Vit d liu vo file excel thnh cng");

        //?ng workbook
        workbook.close();

        // ?ng stream
        os.close();

    } catch (FileNotFoundException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:control.GhiFile.java

public void taoFileKhachHang(ArrayList<KhachHang> dsKhachHang) {

    // ?t tn ct/*from w w w  . j  av  a 2  s  . com*/
    XSSFRow rowTitle = sheet.createRow(0);
    rowTitle.createCell(0).setCellValue("M khch hng");
    rowTitle.createCell(1).setCellValue("Tn tn khch hng");
    rowTitle.createCell(2).setCellValue("N hin ti");
    rowTitle.createCell(3).setCellValue("?in thoi");
    rowTitle.createCell(4).setCellValue("Ngy sinh");

    int rowNum = sheet.getLastRowNum();
    for (int i = 0; i < dsKhachHang.size(); i++) {
        rowNum++;
        XSSFRow row = sheet.createRow(rowNum);

        KhachHang kh = dsKhachHang.get(i);

        row.createCell(0).setCellValue(kh.mMaKhachHang);
        row.createCell(1).setCellValue(kh.mTenKhachHang);
        row.createCell(2).setCellValue(kh.mMaCongNoKhachHang);
        // n hin ti
        row.createCell(3).setCellValue(kh.mDienThoai);
        row.createCell(4).setCellValue(kh.mNgaySinh);
    }
    File myFile = new File(path());
    FileOutputStream os = null;
    try {

        // Khi to Stream  ghi file
        os = new FileOutputStream(myFile);

        //Ghi d liu t workbook vo 
        workbook.write(os);
        System.out.println("Vit d liu vo file excel thnh cng");

        //?ng workbook
        workbook.close();

        // ?ng stream
        os.close();

    } catch (FileNotFoundException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {

        Logger.getLogger(GhiFile.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:controller.application.employee.ViewEmployeController.java

private void toExcel(ArrayList<ToExcelEmployee> lst, ArrayList<RFIDTimestamp> times, File file, Timestamp from,
        Timestamp to) throws IOException {

    try {/*from   ww  w.j av a  2s  .  co  m*/
        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet spreadsheet = workbook.createSheet("Total arbetad tid " + file.getName());
        XSSFRow row = spreadsheet.createRow(0);
        XSSFCell cell;
        cell = row.createCell(0);
        cell.setCellValue("Frnamn:");
        cell = row.createCell(1);
        cell.setCellValue("Efternamn:");
        cell = row.createCell(2);
        cell.setCellValue("Anstllningsnummer:");
        cell = row.createCell(3);
        cell.setCellValue("Individuell tid (h) from.: " + (from.toString() + " tom.: " + to.toString())
                .replaceAll("(\\s)((\\p{Digit}{2}:){2}\\p{Digit}{2})\\..", ""));
        Double totAllTime = 0.0;
        for (int i = 1; i <= lst.size(); i++) {
            row = spreadsheet.createRow(i);
            cell = row.createCell(0);
            cell.setCellValue(lst.get(i - 1).surname);
            cell = row.createCell(1);
            cell.setCellValue(lst.get(i - 1).lastname);
            cell = row.createCell(2);
            cell.setCellValue(lst.get(i - 1).id);
            cell = row.createCell(3);
            cell.setCellValue(lst.get(i - 1).time);
            totAllTime += lst.get(i - 1).time;
            if (i == lst.size()) {
                row = spreadsheet.createRow(i + 1);
                cell = row.createCell(3);
                cell.setCellValue("Sammanstllning:");
                row = spreadsheet.createRow(i + 2);
                cell = row.createCell(3);
                cell.setCellValue(totAllTime);
            }

        }

        XSSFSheet spreadsheetTimes = workbook.createSheet("Tider");
        row = spreadsheetTimes.createRow(0);
        cell = row.createCell(0);
        cell.setCellValue("RFID");
        cell = row.createCell(1);
        cell.setCellValue("IN/UT");
        cell = row.createCell(2);
        cell.setCellValue("Datum/Tid");

        for (int i = 1; i <= times.size(); i++) {
            row = spreadsheetTimes.createRow(i);
            cell = row.createCell(0);
            cell.setCellValue(times.get(i - 1).getRFID().toString());
            cell = row.createCell(1);
            cell.setCellValue(times.get(i - 1).getInOut());
            cell = row.createCell(2);
            cell.setCellValue(times.get(i - 1).getTime());
        }
        for (int k = 0; k < spreadsheet.getRow(0).getLastCellNum(); k++) {
            spreadsheet.autoSizeColumn(k);
        }
        for (int j = 0; j < spreadsheetTimes.getRow(0).getLastCellNum(); j++) {
            spreadsheetTimes.autoSizeColumn(j);
        }

        try (FileOutputStream out = new FileOutputStream(file)) {
            workbook.write(out);
        }
        System.out.println(file.getName() + " written successfully");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:courtscheduler.persistence.CourtScheduleIO.java

License:Apache License

private void printMatch(XSSFRow dataRow, Match match, CourtScheduleInfo info) {
    int cellNumber = 0;
    // TEAM//ww  w. j av  a2s . c  om
    String teamName1 = match.getTeam1().getTeamName();
    dataRow.createCell(cellNumber++).setCellValue(teamName1);

    // VS
    String vs = "vs.";
    dataRow.createCell(cellNumber++).setCellValue(vs);

    // OPPONENT
    String teamName2 = match.getTeam2().getTeamName();
    dataRow.createCell(cellNumber++).setCellValue(teamName2);

    // CONFERENCE
    String conference = match.getConference();

    dataRow.createCell(cellNumber++).setCellValue(conference);

    // DAY
    Integer matchDateIndex = match.getMatchSlot().getDay();
    LocalDate matchDate = info.getConferenceStartDate().plusDays(matchDateIndex);
    String day = matchDate.dayOfWeek().getAsText();
    dataRow.createCell(cellNumber++).setCellValue(day);

    // DATE
    String date = matchDate.toString();
    if (Main.LOG_LEVEL > 1) {
        date = date + " [" + matchDateIndex + "]";
    }
    dataRow.createCell(cellNumber++).setCellValue(date);

    // TIME
    Integer matchTime = match.getMatchSlot().getTime();
    String time = info.getHumanReadableTime(matchTime);
    if (Main.LOG_LEVEL > 1) {
        time = time + " [" + matchTime + "]";
    }
    dataRow.createCell(cellNumber++).setCellValue(time);

    // COURT
    Integer courtId = match.getMatchSlot().getCourt();
    // normal people like their courts indexed from one, not zero,
    // so add one if we're printing for the client
    dataRow.createCell(cellNumber++).setCellValue(courtId + (Main.LOG_LEVEL > 1 ? 0 : 1));

    if (!match.getCanPlayInCurrentSlot()) {
        dataRow.createCell(cellNumber).setCellValue("WARNING: Team is scheduled when they cannot play");
    } else if (match.wasPostProcessed()) {
        dataRow.createCell(cellNumber)
                .setCellValue("VERIFY: Check that this match meets DH/B2B/NST constraints");
    }
}

From source file:coverageqc.functions.MyExcelEditor.java

public static void excelRowCreator(XSSFRow currentRow, Variant currentVariant, String tsvHeadingLine,
        String variantTsvDataLine, ArrayList<DoNotCall> donotcalls) {

    //list of possible cells to highlight
    Boolean filterCell = false;//from w ww.  j  av a2  s.c  om
    Boolean altVariantFreqCell = false;
    Boolean consequenceCell = false;
    Boolean alleleMinorCell = false;
    //XSSFCellStyle cellStyle = currentRow.getRowStyle();
    Cell cellInterp = currentRow.createCell(0);
    // XSSFCellStyle cellStyle = (XSSFCellStyle)cellInterp.getCellStyle();

    XSSFCellStyle cellStyle = getDefaultCellStyle(currentRow);

    String textOnInterp = "";
    //cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    // XSSFColor myColor;
    // Tom Addition
    //if any of these the text on Interp is "Do Not Call"
    if (currentVariant.consequence.equals("synonymous_variant")
            || currentVariant.altVariantFreq.floatValue() <= 5
            || currentVariant.typeOfDoNotCall.equals("Don't call, always")) {
        textOnInterp = textOnInterp + "Do Not Call -";

        // cellStyle.setFillForegroundColor(new XSSFColor(Color.GRAY));
        cellStyle = getGrayCellStyle(currentRow);

        if (currentVariant.typeOfDoNotCall.equals("Don't call, always")) {

            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " on lab list of definitive do-not-calls";
            } else {
                textOnInterp = textOnInterp + ", on lab list of definitive do-not-calls";
            }

        }
        if (currentVariant.consequence.equals("synonymous_variant")) {
            consequenceCell = true;
            //if the string size 
            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " synonymous variant";
            } else {
                textOnInterp = textOnInterp + ", synonymous variant";
            }

        }
        if (currentVariant.altVariantFreq.floatValue() <= 5) {
            altVariantFreqCell = true;
            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " variant <5%";
            } else {
                textOnInterp = textOnInterp + ", variant <5%";
            }

        }

    }
    //if any of these the text on Interp is "Warning"
    if ((currentVariant.onTheDoNotCallList && (!currentVariant.typeOfDoNotCall.equals("Don't call, always")))
            || currentVariant.alleleFreqGlobalMinor.floatValue() > 1
            || !(currentVariant.filters.equals("PASS"))) {

        //cellStyle.setFillForegroundColor(new XSSFColor(Color.GRAY));
        cellStyle = getGrayCellStyle(currentRow);
        if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
            textOnInterp = textOnInterp + "WARNING -";
        } else {
            textOnInterp = textOnInterp + ", WARNING -";
        }

        if ((currentVariant.onTheDoNotCallList
                && !(currentVariant.typeOfDoNotCall.equals("Don't call, always")))) {

            if (currentVariant.typeOfDoNotCall.contains("In same location")) {
                if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                    textOnInterp = textOnInterp + "in same location as lab list of do-not-calls";
                } else {
                    textOnInterp = textOnInterp + ", in same location as lab list of do-not-calls";
                }
            } else {
                if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                    textOnInterp = textOnInterp + "on lab list of possible do-not-calls ";
                } else {
                    textOnInterp = textOnInterp + ", on lab list of possible do-not-calls - ";
                }
            }

        }

        if (currentVariant.alleleFreqGlobalMinor.floatValue() > 1) {
            alleleMinorCell = true;

            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " MAF >1%";
            } else {
                textOnInterp = textOnInterp + ", MAF >1%";
            }

        }

        if (!(currentVariant.filters.equals("PASS"))) {
            filterCell = true;
            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " Quality Filter = " + currentVariant.filters;
            } else {
                textOnInterp = textOnInterp + ", Quality Filter = " + currentVariant.filters;
            }

        }

    } //end if statement saying it is on Warning

    //now creating both of the columns
    cellInterp.setCellStyle(cellStyle);
    cellInterp.setCellValue(textOnInterp);
    Cell cellInterp2 = currentRow.createCell(1);
    cellInterp2.setCellStyle(cellStyle);
    cellInterp2.setCellValue(textOnInterp);

    //adding TSV dataline to output excel file
    // row = sheet.createRow(rownum++);
    String[] headingsArray = tsvHeadingLine.split("\t");

    HashMap<String, Integer> headings = new HashMap<String, Integer>();
    for (int x = 0; x < headingsArray.length; x++) {
        headings.put(headingsArray[x].substring(0, headingsArray[x].indexOf("_")), x);
    }
    String[] dataArray = variantTsvDataLine.split("\t");

    for (int x = 0; x < dataArray.length; x++) {
        Cell cell = currentRow.createCell(x + 2);

        if ((headingsArray[x].contains("Filters_") && filterCell)
                || (altVariantFreqCell && (headingsArray[x].contains("Alt Variant Freq_")))
                || (headingsArray[x].contains("Consequence_") && consequenceCell)
                || (headingsArray[x].contains("Allele Freq Global Minor_") && alleleMinorCell)) {
            // cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
            // cellStyle.setFillForegroundColor(new XSSFColor(Color.GRAY));
            cellStyle = getGrayCellStyle(currentRow);
        } else {
            cellStyle = getDefaultCellStyle(currentRow);
            //cellStyle.setFillForegroundColor(new XSSFColor(Color.white));
        }
        cell.setCellStyle(cellStyle);
        // XSSFCellStyle style = workbookcopy.createCellStyle();
        // XSSFColor myColor = new XSSFColor(Color.RED);
        // style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
        // style.setFillForegroundColor(myColor);

        cell.setCellValue(dataArray[x]);

    }

    // return currentRow;
}

From source file:coverageqc.functions.MyExcelEditor.java

public static void excelHeadingCreator(XSSFRow currentRow, String variantTsvHeadingLine) {

    XSSFCellStyle cellStyle = getDefaultCellStyle(currentRow);

    String[] headingsArray = variantTsvHeadingLine.split("\t");

    for (int x = 0; x < headingsArray.length + 2; x++) {

        Cell cell = currentRow.createCell(x);

        // cell.setCellStyle(cellStyle);
        if (x == 0) {

            cell.setCellStyle(cellStyle);
            cell.setCellValue("Fellow's Interpretation");

        } else if (x == 1) {
            cell.setCellStyle(cellStyle);
            cell.setCellValue("Attending Pathologist Interpretation");
        } else {/*www .  ja v a  2 s  .  c  om*/
            if (headingsArray[x - 2].contains("Gene_") || headingsArray[x - 2].contains("Variant_")
                    || headingsArray[x - 2].contains("Chr_") || headingsArray[x - 2].contains("Coordinate_")
                    || headingsArray[x - 2].contains("Type_") || headingsArray[x - 2].contains("Genotype_")
                    || headingsArray[x - 2].contains("Coordinate_")
                    || headingsArray[x - 2].contains("Filters_")) {
                cellStyle = getDefaultCellStyle(currentRow);
                cellStyle.setRotation((short) 0);
            } else {
                cellStyle = getDefaultCellStyle(currentRow);
                cellStyle.setRotation((short) 90);
            }

            cell.setCellStyle(cellStyle);
            cell.setCellValue(headingsArray[x - 2]);
        }

    }

    //return currentRow;
}

From source file:coverageqc.functions.MyExcelGenerator.java

public void excelRowCreator(int currentRowNum, String currentSheet, Variant currentVariant,
        String variantTsvDataLine, ArrayList<DoNotCall> donotcalls) {

    XSSFRow currentRow = this.workbookcopy.getSheet(currentSheet).createRow(currentRowNum);
    //list of possible cells to highlight
    Boolean filterCell = false;//from   w ww .j  av  a 2s  . c  o  m
    Boolean altVariantFreqCell = false;
    Boolean consequenceCell = false;
    Boolean alleleMinorCell = false;
    Boolean containsDoNotCall = false;
    //XSSFCellStyle cellStyle = currentRow.getRowStyle();
    // Cell cellInterp = currentRow.createCell(0);
    // XSSFCellStyle cellStyle = (XSSFCellStyle)cellInterp.getCellStyle();

    XSSFCellStyle cellStyle = getDefaultCellStyle(currentRow, Color.WHITE);

    String textOnInterp = "";
    //cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    // XSSFColor myColor;
    // Tom Addition
    //if any of these the text on Interp is "Do Not Call"
    if (currentVariant.consequence.contains("synonymous_variant")
            || currentVariant.altVariantFreq.floatValue() <= 5
            || currentVariant.typeOfDoNotCall.equals("Don't call, always")) {
        textOnInterp = textOnInterp + "Do Not Call -";

        // cellStyle.setFillForegroundColor(new XSSFColor(Color.GRAY));
        cellStyle = getDefaultCellStyle(currentRow, Color.GRAY);
        containsDoNotCall = true;

        if (currentVariant.typeOfDoNotCall.equals("Don't call, always")) {

            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " on lab list of definitive do-not-calls";
            } else {
                textOnInterp = textOnInterp + ", on lab list of definitive do-not-calls";
            }

        }
        if (currentVariant.consequence.contains("synonymous_variant")) {
            consequenceCell = true;
            //if the string size 
            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " synonymous variant";
            } else {
                textOnInterp = textOnInterp + ", synonymous variant";
            }

        }
        if (currentVariant.altVariantFreq.floatValue() <= 5) {
            altVariantFreqCell = true;
            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " variant <5%";
            } else {
                textOnInterp = textOnInterp + ", variant <5%";
            }

        }

    }
    //if any of these the text on Interp is "Warning"
    if ((currentVariant.onTheDoNotCallList && (!currentVariant.typeOfDoNotCall.equals("Don't call, always")))
            || currentVariant.alleleFreqGlobalMinor.floatValue() > 1
            || !(currentVariant.filters.equals("PASS"))) {

        //cellStyle.setFillForegroundColor(new XSSFColor(Color.GRAY));
        // System.out.println(currentVariant.gene);
        if (!containsDoNotCall) {
            cellStyle = getDefaultCellStyle(currentRow, Color.YELLOW);
        }
        if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
            textOnInterp = textOnInterp + "WARNING -";
        } else {
            textOnInterp = textOnInterp + ", WARNING -";
        }

        if ((currentVariant.onTheDoNotCallList
                && !(currentVariant.typeOfDoNotCall.equals("Don't call, always")))) {

            if (currentVariant.typeOfDoNotCall.contains("In same location")) {
                if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                    textOnInterp = textOnInterp + "in same location as lab list of do-not-calls";
                } else {
                    textOnInterp = textOnInterp + ", in same location as lab list of do-not-calls";
                }
            } else {
                if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                    textOnInterp = textOnInterp + "on lab list of possible do-not-calls ";
                } else {
                    textOnInterp = textOnInterp + ", on lab list of possible do-not-calls - ";
                }
            }

        }

        if (currentVariant.alleleFreqGlobalMinor > 1) {
            alleleMinorCell = true;

            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " MAF >1%";
            } else {
                textOnInterp = textOnInterp + ", MAF >1%";
            }

        }

        if (!(currentVariant.filters.equals("PASS"))) {
            filterCell = true;
            if (textOnInterp.lastIndexOf("-") == textOnInterp.length() - 1) {
                textOnInterp = textOnInterp + " Quality Filter = " + currentVariant.filters;
            } else {
                textOnInterp = textOnInterp + ", Quality Filter = " + currentVariant.filters;
            }

        }

    } //end if statement saying it is on Warning

    //now creating three columns of interps 
    for (int x = 0; x <= 2; x++) {
        Cell cellInterp = currentRow.createCell(x);
        cellInterp.setCellStyle(cellStyle);
        cellInterp.setCellValue(textOnInterp);
    }

    //adding TSV dataline to output excel file
    // row = sheet.createRow(rownum++);
    // String[] headingsArray = tsvHeadingLine.split("\t");

    //  HashMap<String, Integer> headings = new HashMap<String, Integer>();
    //    for(int x = 0; x < headingsArray.length; x++) {
    //      headings.put(headingsArray[x].substring(0, headingsArray[x].indexOf("_")), x);
    //       }
    String[] dataArray = variantTsvDataLine.split("\t");

    for (int x = 0; x < dataArray.length; x++) {
        Cell cell = currentRow.createCell(x + 3);
        //System.out.println(x);
        //System.out.println(this.tsvRearrangeConversion.get(x));
        if ((this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Filters_") && filterCell)
                || (this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)]
                        .contains("Allele Freq Global Minor_") && alleleMinorCell)) {
            // cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
            // cellStyle.setFillForegroundColor(new XSSFColor(Color.GRAY));
            cellStyle = getDefaultCellStyle(currentRow, Color.YELLOW);
        } else if ((this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Consequence_")
                && consequenceCell)
                || (altVariantFreqCell && (this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)]
                        .contains("Alt Variant Freq_")))) {
            cellStyle = getDefaultCellStyle(currentRow, Color.GRAY);
        } else {
            cellStyle = getDefaultCellStyle(currentRow, Color.WHITE);
            //cellStyle.setFillForegroundColor(new XSSFColor(Color.white));
        }
        cell.setCellStyle(cellStyle);
        // XSSFCellStyle style = workbookcopy.createCellStyle();
        // XSSFColor myColor = new XSSFColor(Color.RED);
        // style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
        // style.setFillForegroundColor(myColor);

        cell.setCellValue(dataArray[this.tsvRearrangeConversion.get(x)]);

    }

    // return currentRow;
}

From source file:coverageqc.functions.MyExcelGenerator.java

public void excelHeadingCreator(String specifiedsheet, String headingLine) {
    XSSFSheet currentSheet = workbookcopy.createSheet(specifiedsheet);
    XSSFRow currentRow = currentSheet.createRow(0);

    XSSFCellStyle cellStyle;//from  w w w . j av  a 2s .co m

    // String[] originalHeadingsArray = headingLine.split("\t");
    this.originalHeadingsArray = headingLine.split("\t");
    ;

    HashMap<String, Integer> headings = new HashMap<String, Integer>();
    for (int x = 0; x < originalHeadingsArray.length; x++) {
        headings.put(originalHeadingsArray[x].substring(0, originalHeadingsArray[x].indexOf("_")), x);
    }
    this.setRearrangedHashMap(headings);
    this.originalHeadings = headings;

    //the headers for the first three columns
    for (int x = 0; x < 3; x++) {
        Cell cell = currentRow.createCell(x);
        cellStyle = getDefaultCellStyle(currentRow, Color.WHITE);
        if (x == 0 || x == 1) {

            cell.setCellStyle(cellStyle);
            if (x == 0) {
                cell.setCellValue("Tom's Interpretation");
                //cell.setCellValue("Fellow1's Interpretation");
            } else {
                cell.setCellValue("Christina's Interpretation");
                //cell.setCellValue("Fellow2's Interpretation");
            }

        } else if (x == 2) {
            cell.setCellStyle(cellStyle);
            cell.setCellValue("Attending Pathologist Interpretation");
        }
    }

    for (int x = 0; x < originalHeadingsArray.length; x++) {

        //plus three because have three header columns
        Cell cell = currentRow.createCell(x + 3);
        cellStyle = getDefaultCellStyle(currentRow, Color.WHITE);
        // cell.setCellStyle(cellStyle);
        if (this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Gene_")
                || this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Variant_")
                || this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)].contains("Chr_"))
        //  ||originalHeadingsArray[x].contains("Coordinate_")
        //   ||originalHeadingsArray[x].contains("Type_"))
        //  ||originalHeadingsArray[x-3].contains("Genotype_")
        // ||originalHeadingsArray[x-3].contains("Coordinate_")
        //  ||originalHeadingsArray[x-3].contains("Filters_"))
        {
            cellStyle.setRotation((short) 0);
        } else {
            cellStyle.setRotation((short) 90);
        }

        cell.setCellStyle(cellStyle);
        //cell.setCellValue(originalHeadingsArray[x-3]);
        // this.tsvRearrangeConversion.get(x)
        cell.setCellValue(this.originalHeadingsArray[this.tsvRearrangeConversion.get(x)]);
        //cell.setCellValue(headinsArray[headingsConversion.get(x-3)]);

    } //end for loop

    //return currentRow;
}