Example usage for org.apache.poi.ss.usermodel CellStyle setBorderRight

List of usage examples for org.apache.poi.ss.usermodel CellStyle setBorderRight

Introduction

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

Prototype

void setBorderRight(BorderStyle border);

Source Link

Document

set the type of border to use for the right border of the cell

Usage

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeColumnStt() {
    CellStyle cellStyle = wb.createCellStyle();
    cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyle.setBorderRight(CellStyle.BORDER_THIN);
    cellStyle.setBorderTop(CellStyle.BORDER_THIN);
    cellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    cellStyle.setWrapText(false);/*from www .j  a v a 2s  . co m*/
    return cellStyle;

}

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeAlignLeft(Boolean wraptext) {

    CellStyle cellStyleLeft = wb.createCellStyle();
    cellStyleLeft.setAlignment(CellStyle.ALIGN_LEFT);
    cellStyleLeft.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleLeft.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyleLeft.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyleLeft.setBorderRight(CellStyle.BORDER_THIN);
    cellStyleLeft.setBorderTop(CellStyle.BORDER_THIN);
    cellStyleLeft.setWrapText(wraptext);
    return cellStyleLeft;

}

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeAlignCenter(Boolean wraptext) {
    CellStyle cellStyleCenter = wb.createCellStyle();
    cellStyleCenter.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyleCenter.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleCenter.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyleCenter.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyleCenter.setBorderRight(CellStyle.BORDER_THIN);
    cellStyleCenter.setBorderTop(CellStyle.BORDER_THIN);
    cellStyleCenter.setWrapText(wraptext);
    return cellStyleCenter;
}

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeHeader(Boolean wraptext) {
    CellStyle cellStyle = wb.createCellStyle();
    cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyle.setBorderRight(CellStyle.BORDER_THIN);
    cellStyle.setBorderTop(CellStyle.BORDER_THIN);
    cellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    cellStyle.setWrapText(wraptext);//from w w  w  .j ava2  s  . c o  m
    return cellStyle;
}

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeFormatNumber(Boolean wraptext) {
    CellStyle cellStyleFormatNumber = wb.createCellStyle();
    cellStyleFormatNumber.setDataFormat((short) BuiltinFormats.getBuiltinFormat("#,##0"));
    cellStyleFormatNumber.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyleFormatNumber.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyleFormatNumber.setBorderRight(CellStyle.BORDER_THIN);
    cellStyleFormatNumber.setBorderTop(CellStyle.BORDER_THIN);
    return cellStyleFormatNumber;
}

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeAlignRight(Boolean wraptext) {
    CellStyle cellStyleRight = wb.createCellStyle();
    cellStyleRight.setAlignment(CellStyle.ALIGN_RIGHT);
    cellStyleRight.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyleRight.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyleRight.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyleRight.setBorderRight(CellStyle.BORDER_THIN);
    cellStyleRight.setBorderTop(CellStyle.BORDER_THIN);
    cellStyleRight.setWrapText(wraptext);
    return cellStyleRight;
}

From source file:com.crimelab.service.ChemistryServiceImpl.java

@Override
public Workbook createMonthlyReport(HttpSession session, String month) {
    Workbook wb = null;/*from w w  w .  jav  a  2  s . com*/

    try {
        InputStream inp = session.getServletContext()
                .getResourceAsStream("/WEB-INF/templates/DrugMonthlyReport.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);
        CellStyle cs1 = wb.createCellStyle();
        CellStyle cs2 = wb.createCellStyle();
        CellStyle bl = wb.createCellStyle();
        CellStyle br = wb.createCellStyle();
        CellStyle bt = wb.createCellStyle();
        CellStyle bb = wb.createCellStyle();
        CellStyle stf = wb.createCellStyle();
        cs1.setWrapText(true);
        cs2.setAlignment(ALIGN_CENTER);
        bt.setBorderTop(BORDER_THIN);
        bb.setBorderBottom(BORDER_THIN);
        bl.setBorderLeft(BORDER_THIN);
        br.setBorderRight(BORDER_THIN);
        stf.setShrinkToFit(true);

        Row intro1 = sheet.createRow(7);
        Cell in1 = intro1.createCell(0);//.setCellValue("DRUG INVETORY COVERED PERIOD JANUARY-DECEMBER CY-" +month.split("-")[0]);
        in1.setCellValue("DRUG INVENTORY COVERED PERIOD JANUARY-DECEMBER CY-" + month.split("-")[0]);
        in1.setCellStyle(cs1);
        in1.setCellStyle(cs2);

        Row intro2 = sheet.createRow(9);
        Cell in2 = intro2.createCell(0);//.setCellValue("SUMMARY OF SEIZED/SURRENDERED/RECOVERED OF DRUG EVIDENCES FROM NEGATION OPERATIONS FROM LAW ENFORCEMENTS, PHARMACEUTICAL COMPANIES AND SIMILAR ESTABLISHMENTS FOR THE MONTH OF "+month);
        in2.setCellValue(
                "SUMMARY OF SEIZED/SURRENDERED/RECOVERED OF DRUG EVIDENCES FROM NEGATION OPERATIONS FROM LAW ENFORCEMENTS, PHARMACEUTICAL COMPANIES AND SIMILAR ESTABLISHMENTS FOR THE MONTH OF "
                        + month);
        in2.setCellStyle(cs1);
        in2.setCellStyle(cs2);
        in2.setCellStyle(stf);

        int ctr = 12; //initial
        Row row = sheet.createRow(ctr);
        month = month.split("-")[1];

        //System.out.println("GAC " + chemistryDAO.getAllChemistry(month).isEmpty());
        for (Chemistry chemistry : chemistryDAO.getAllChemistry(month)) {
            //System.out.println("Test " + chemistry.getTimeDateReceived());
            Cell cell0 = row.createCell(0);
            cell0.setCellValue(chemistry.getTimeDateReceived());
            cell0.setCellStyle(bt);
            cell0.setCellStyle(bb);
            cell0.setCellStyle(bl);
            cell0.setCellStyle(br);

            Cell cell1 = row.createCell(1);//.setCellValue(chemistry.getReportNo());
            cell1.setCellValue(chemistry.getReportNo());
            cell1.setCellStyle(bt);
            cell1.setCellStyle(bb);
            cell1.setCellStyle(bl);
            cell1.setCellStyle(br);

            Cell cell2 = row.createCell(2);//.setCellValue(chemistry.getRequestingParty());
            cell2.setCellValue(chemistry.getRequestingParty());
            cell2.setCellStyle(bt);
            cell2.setCellStyle(bb);
            cell2.setCellStyle(bl);
            cell2.setCellStyle(br);

            Cell cell3 = row.createCell(3);//.setCellValue(chemistry.getDescriptionOfEvidence());
            cell3.setCellValue(chemistry.getDescriptionOfEvidence());
            cell3.setCellStyle(bt);
            cell3.setCellStyle(bb);
            cell3.setCellStyle(bl);
            cell3.setCellStyle(br);

            Cell cell4 = row.createCell(4);//.setCellValue(chemistry.getSpecimenWeight());
            cell4.setCellValue(chemistry.getSpecimenWeight());
            cell4.setCellStyle(bt);
            cell4.setCellStyle(bb);
            cell4.setCellStyle(bl);
            cell4.setCellStyle(br);

            Cell cell5 = row.createCell(5);//.setCellValue(chemistry.getCustody());
            cell5.setCellValue(chemistry.getCustody());
            cell5.setCellStyle(bt);
            cell5.setCellStyle(bb);
            cell5.setCellStyle(bl);
            cell5.setCellStyle(br);

            Cell cell6 = row.createCell(6);//.setCellValue(chemistry.getSuspects());
            cell6.setCellValue(chemistry.getSuspects());
            cell6.setCellStyle(bt);
            cell6.setCellStyle(bb);
            cell6.setCellStyle(bl);
            cell6.setCellStyle(br);

            Cell cell7 = row.createCell(7);//.setCellValue(chemistry.getTypeOfOperation());
            cell7.setCellValue(chemistry.getTypeOfOperation());
            cell7.setCellStyle(bt);
            cell7.setCellStyle(bb);
            cell7.setCellStyle(bl);
            cell7.setCellStyle(br);

            Cell cell8 = row.createCell(8);//.setCellValue(chemistry.getPlaceOfOperation());
            cell8.setCellValue(chemistry.getPlaceOfOperation());
            cell8.setCellStyle(bt);
            cell8.setCellStyle(bb);
            cell8.setCellStyle(bl);
            cell8.setCellStyle(br);

            row = sheet.createRow(ctr += 1);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return wb;
}

From source file:com.crimelab.service.CriminalServiceImpl.java

@Override
public Workbook createTenprintsCards(HttpSession session, String month) {
    Workbook wb = null;//  ww w  .j  a v a2  s .  c  o m

    try {
        InputStream inp = session.getServletContext()
                .getResourceAsStream("/WEB-INF/templates/TenprintsCards.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);
        CellStyle cs1 = wb.createCellStyle();
        CellStyle cs2 = wb.createCellStyle();
        CellStyle bl = wb.createCellStyle();
        CellStyle br = wb.createCellStyle();
        CellStyle bt = wb.createCellStyle();
        CellStyle bb = wb.createCellStyle();
        cs1.setWrapText(true);
        cs2.setAlignment(ALIGN_CENTER);
        bt.setBorderTop(BORDER_THIN);
        bb.setBorderBottom(BORDER_THIN);
        bl.setBorderLeft(BORDER_THIN);
        br.setBorderRight(BORDER_THIN);

        Row intro1 = sheet.createRow(9);
        Cell in1 = intro1.createCell(0);
        in1.setCellValue("Submitted Tenprints Cards from " + month.split("-")[0]);
        in1.setCellStyle(cs1);
        in1.setCellStyle(cs2);

        int ctr = 11; //initial
        Row row = sheet.createRow(ctr);
        month = month.split("-")[1];

        //JOptionPane.showMessageDialog(null, criminalDAO.getAllCriminal(month));
        for (Criminal criminal : criminalDAO.getAllCriminal(month)) {
            //JOptionPane.showMessageDialog(null, criminal.getReportNo());

            Cell cell2 = row.createCell(2);//.setCellValue(criminal.getRequestingParty());
            cell2.setCellValue(criminal.getLastName());
            cell2.setCellStyle(bt);
            cell2.setCellStyle(bb);
            cell2.setCellStyle(bl);
            cell2.setCellStyle(br);

            Cell cell3 = row.createCell(3);//.setCellValue(criminal.getDescriptionOfEvidence());
            cell3.setCellValue(criminal.getFirstName());
            cell2.setCellStyle(bt);
            cell2.setCellStyle(bb);
            cell3.setCellStyle(bl);
            cell3.setCellStyle(br);

            Cell cell4 = row.createCell(4);//.setCellValue(criminal.getSpecimenWeight());
            cell4.setCellValue(criminal.getMiddleName());
            cell4.setCellStyle(bt);
            cell4.setCellStyle(bb);
            cell4.setCellStyle(bl);
            cell4.setCellStyle(br);

            Cell cell5 = row.createCell(5);//.setCellValue(criminal.getCustody());
            cell5.setCellValue(criminal.getTimeDateArrest());
            cell5.setCellStyle(bt);
            cell5.setCellStyle(bb);
            cell5.setCellStyle(bl);
            cell5.setCellStyle(br);

            Cell cell6 = row.createCell(6);//.setCellValue(criminal.getSuspects());
            cell6.setCellValue(criminal.getOffenseCharge());
            cell6.setCellStyle(bt);
            cell6.setCellStyle(bb);
            cell6.setCellStyle(bl);
            cell6.setCellStyle(br);

            row = sheet.createRow(ctr += 1);

            return wb;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return wb;
}

From source file:com.crimelab.service.FirearmsServiceImpl.java

@Override
public Workbook createFirearmsCases(HttpSession session, String month) {
    Workbook wb = null;/*from  w  ww  .  j a v a  2  s .com*/

    try {
        InputStream inp = session.getServletContext()
                .getResourceAsStream("/WEB-INF/templates/FirearmsCases.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);
        CellStyle cs1 = wb.createCellStyle();
        CellStyle cs2 = wb.createCellStyle();
        CellStyle bl = wb.createCellStyle();
        CellStyle br = wb.createCellStyle();
        CellStyle bt = wb.createCellStyle();
        CellStyle bb = wb.createCellStyle();
        cs1.setWrapText(true);
        cs2.setAlignment(ALIGN_CENTER);
        bt.setBorderTop(BORDER_THIN);
        bb.setBorderBottom(BORDER_THIN);
        bl.setBorderLeft(BORDER_THIN);
        br.setBorderRight(BORDER_THIN);

        Row intro1 = sheet.createRow(9);
        Cell in1 = intro1.createCell(0);
        in1.setCellValue("Period Covered:");
        in1.setCellStyle(cs1);
        in1.setCellStyle(cs2);

        Row intro2 = sheet.createRow(10);
        Cell in2 = intro2.createCell(0);
        in1.setCellValue(month.split("-")[0]);
        in1.setCellStyle(cs1);
        in1.setCellStyle(cs2);

        int ctr = 12; //initial
        Row row = sheet.createRow(ctr);
        month = month.split("-")[1];

        //JOptionPane.showMessageDialog(null, firearmsDAO.getAllFirearms(month));
        for (Firearms firearms : firearmsDAO.getAllFirearms(month)) {
            //JOptionPane.showMessageDialog(null, firearms.getReportNo());
            Cell cell0 = row.createCell(0);
            cell0.setCellValue(firearms.getReportNo());
            cell0.setCellStyle(bt);
            cell0.setCellStyle(bb);
            cell0.setCellStyle(bl);
            cell0.setCellStyle(br);

            Cell cell1 = row.createCell(1);//.setCellValue(firearms.getReportNo());
            cell1.setCellValue(firearms.getExaminerName());
            cell1.setCellStyle(bt);
            cell1.setCellStyle(bb);
            cell1.setCellStyle(bl);
            cell1.setCellStyle(br);

            Cell cell2 = row.createCell(2);//.setCellValue(firearms.getRequestingParty());
            cell2.setCellValue(firearms.getCaseType());
            cell2.setCellStyle(bt);
            cell2.setCellStyle(bb);
            cell2.setCellStyle(bl);
            cell2.setCellStyle(br);

            Cell cell3 = row.createCell(3);//.setCellValue(firearms.getDescriptionOfEvidence());
            cell3.setCellValue(firearms.getVictim());
            cell2.setCellStyle(bt);
            cell2.setCellStyle(bb);
            cell3.setCellStyle(bl);
            cell3.setCellStyle(br);

            Cell cell4 = row.createCell(4);//.setCellValue(firearms.getSpecimenWeight());
            cell4.setCellValue(firearms.getSuspect());
            cell4.setCellStyle(bt);
            cell4.setCellStyle(bb);
            cell4.setCellStyle(bl);
            cell4.setCellStyle(br);

            Cell cell5 = row.createCell(5);//.setCellValue(firearms.getCustody());
            cell5.setCellValue(firearms.getTimeDateIncident());
            cell5.setCellStyle(bt);
            cell5.setCellStyle(bb);
            cell5.setCellStyle(bl);
            cell5.setCellStyle(br);

            Cell cell6 = row.createCell(6);//.setCellValue(firearms.getSuspects());
            cell6.setCellValue(firearms.getPlaceOfIncident());
            cell6.setCellStyle(bt);
            cell6.setCellStyle(bb);
            cell6.setCellStyle(bl);
            cell6.setCellStyle(br);

            Cell cell7 = row.createCell(7);//.setCellValue(firearms.getTypeOfOperation());
            cell7.setCellValue(firearms.getRequestingParty());
            cell7.setCellStyle(bt);
            cell7.setCellStyle(bb);
            cell7.setCellStyle(bl);
            cell7.setCellStyle(br);

            Cell cell8 = row.createCell(8);//.setCellValue(firearms.getPlaceOfOperation());
            cell8.setCellValue(firearms.getInvestigator());
            cell8.setCellStyle(bt);
            cell8.setCellStyle(bb);
            cell8.setCellStyle(bl);
            cell8.setCellStyle(br);

            Cell cell9 = row.createCell(9);//.setCellValue(firearms.getPlaceOfOperation());
            cell9.setCellValue(firearms.getCaseStatus());
            cell9.setCellStyle(bt);
            cell9.setCellStyle(bb);
            cell9.setCellStyle(bl);
            cell9.setCellStyle(br);

            row = sheet.createRow(ctr += 1);

            return wb;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return wb;
}

From source file:com.crimelab.service.MedicoLegalServiceImpl.java

@Override
public Workbook createMedicoMonthly(HttpSession session, String month) {
    Workbook wb = null;//from w w w. j  av  a 2  s.  c  om

    try {
        InputStream inp = session.getServletContext()
                .getResourceAsStream("/WEB-INF/templates/MedicoMonthly.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);
        CellStyle cs1 = wb.createCellStyle();
        CellStyle cs2 = wb.createCellStyle();
        CellStyle bl = wb.createCellStyle();
        CellStyle br = wb.createCellStyle();
        CellStyle bt = wb.createCellStyle();
        CellStyle bb = wb.createCellStyle();
        cs1.setWrapText(true);
        cs2.setAlignment(ALIGN_CENTER);
        bt.setBorderTop(BORDER_THIN);
        bb.setBorderBottom(BORDER_THIN);
        bl.setBorderLeft(BORDER_THIN);
        br.setBorderRight(BORDER_THIN);

        Row intro1 = sheet.createRow(9);
        Cell in1 = intro1.createCell(0);
        in1.setCellValue("Period Covered:");
        in1.setCellStyle(cs1);
        in1.setCellStyle(cs2);

        Row intro2 = sheet.createRow(10);
        Cell in2 = intro2.createCell(0);
        in1.setCellValue(month.split("-")[0]);
        in1.setCellStyle(cs1);
        in1.setCellStyle(cs2);

        int ctr = 12; //initial
        Row row = sheet.createRow(ctr);
        month = month.split("-")[1];

        //JOptionPane.showMessageDialog(null, medicoLegalDAO.getAllMedicoLegal(month));
        for (MedicoLegal medicoLegal : medicoLegalDAO.getAllMedicoLegal(month)) {
            //JOptionPane.showMessageDialog(null, medicoLegal.getReportNo());
            Cell cell0 = row.createCell(0);
            cell0.setCellValue(medicoLegal.getCaseNo());
            cell0.setCellStyle(bt);
            cell0.setCellStyle(bb);
            cell0.setCellStyle(bl);
            cell0.setCellStyle(br);

            Cell cell1 = row.createCell(1);//.setCellValue(medicoLegal.getReportNo());
            cell1.setCellValue(medicoLegal.getExaminerName());
            cell1.setCellStyle(bt);
            cell1.setCellStyle(bb);
            cell1.setCellStyle(bl);
            cell1.setCellStyle(br);

            Cell cell2 = row.createCell(2);//.setCellValue(medicoLegal.getRequestingParty());
            cell2.setCellValue(medicoLegal.getCaseType());
            cell2.setCellStyle(bt);
            cell2.setCellStyle(bb);
            cell2.setCellStyle(bl);
            cell2.setCellStyle(br);

            Cell cell3 = row.createCell(3);//.setCellValue(medicoLegal.getDescriptionOfEvidence());
            cell3.setCellValue(medicoLegal.getVictim());
            cell2.setCellStyle(bt);
            cell2.setCellStyle(bb);
            cell3.setCellStyle(bl);
            cell3.setCellStyle(br);

            Cell cell4 = row.createCell(4);//.setCellValue(medicoLegal.getSpecimenWeight());
            cell4.setCellValue(medicoLegal.getSuspect());
            cell4.setCellStyle(bt);
            cell4.setCellStyle(bb);
            cell4.setCellStyle(bl);
            cell4.setCellStyle(br);

            Cell cell5 = row.createCell(5);//.setCellValue(medicoLegal.getCustody());
            cell5.setCellValue(medicoLegal.getTimeDateReceived());
            cell5.setCellStyle(bt);
            cell5.setCellStyle(bb);
            cell5.setCellStyle(bl);
            cell5.setCellStyle(br);

            Cell cell6 = row.createCell(6);//.setCellValue(medicoLegal.getSuspects());
            cell6.setCellValue(medicoLegal.getFindings());
            cell6.setCellStyle(bt);
            cell6.setCellStyle(bb);
            cell6.setCellStyle(bl);
            cell6.setCellStyle(br);

            row = sheet.createRow(ctr += 1);

            return wb;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return wb;
}