Example usage for org.apache.poi.ss.usermodel WorkbookFactory create

List of usage examples for org.apache.poi.ss.usermodel WorkbookFactory create

Introduction

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

Prototype

public static Workbook create(File file) throws IOException, EncryptedDocumentException 

Source Link

Document

Creates the appropriate HSSFWorkbook / XSSFWorkbook from the given File, which must exist and be readable.

Usage

From source file:com.compassplus.gui.MainForm.java

private void openFile(File file) { //xlsFileChooser.getSelectedFile()
    try {//from  ww  w  .  ja  va 2  s  .  co m
        Proposal proposal = new Proposal(config);
        FileInputStream inp = new FileInputStream(file);
        final Workbook wb = WorkbookFactory.create(inp);
        inp.close();
        Sheet s = wb.getSheet("PCTSettings");
        String proposalString = null;
        if (s != null) {
            Row r = s.getRow(0);
            if (r != null) {
                Cell c = r.getCell(0);
                if (c != null) {
                    proposalString = c.getStringCellValue();
                }
            }
        }
        if (proposalString == null) {
            throw new PCTDataFormatException("Proposal not found");
        }
        proposal.init(CommonUtils.getInstance().getDocumentFromString(proposalString));
        //ProposalForm tmpForm = new ProposalForm(proposal, getFrame());
        addProposalForm(proposal, getFrame(), true);
        //tmpForm.setChanged(false);
        if (proposal.containsDeprecated()) {
            JOptionPane.showMessageDialog(getRoot(),
                    "Selected proposal contains deprecated module(s) or capacity(ies).", "Warning",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    } catch (Exception exception) {
        //exception.printStackTrace();
        if (exception instanceof PCTDataFormatException) {
            Logger.getInstance().error(exception);
        }
        JOptionPane.showMessageDialog(getRoot(), "Can't read proposal from specified file", "Error",
                JOptionPane.ERROR_MESSAGE);
    }
}

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

@Override
public Workbook create(Chemistry chemistry, HttpSession session) {
    Workbook wb = null;/*  w  ww.java 2  s  .c om*/
    try {

        //            date = sdf.parse(chemistry.getTimeDateReceived());
        //            sdf.applyPattern("M-dd-yyyy hh:mm:ss a");
        //            dateformat = sdf.format(date);
        InputStream inp = session.getServletContext()
                .getResourceAsStream("/WEB-INF/templates/DefaultDrugs.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);

        Cell examType = findCell(sheet, "$examType");
        Cell reportNo = findCell(sheet, "$reportNo");
        Cell caseType = findCell(sheet, "$caseType");
        Cell suspects = findCell(sheet, "$suspects");
        Cell victims = findCell(sheet, "$victims");
        Cell timeDateReceived = findCell(sheet, "$timeDateReceived");
        Cell requestingParty = findCell(sheet, "$requestingParty");
        Cell specimenSubmitted = findCell(sheet, "$specimenSubmitted");
        Cell purposeOfLabExam = findCell(sheet, "$purposeOfLabExam");
        Cell findings = findCell(sheet, "$findings");
        Cell conclusions = findCell(sheet, "$conclusions");
        Cell remarks = findCell(sheet, "$remarks");
        Cell timeDateCompleted = findCell(sheet, "$timeDateCompleted");
        Cell examinerName = findCell(sheet, "$examinerName");
        Cell examinerRank = findCell(sheet, "$examinerRank");
        Cell examinerPosition = findCell(sheet, "$examinerPosition");
        Cell appName = findCell(sheet, "$appName");
        Cell appRank = findCell(sheet, "$appRank");
        Cell appPosition = findCell(sheet, "$appPosition");
        Cell notedName = findCell(sheet, "$notedName");
        Cell notedRank = findCell(sheet, "$notedRank");
        Cell notedPosition = findCell(sheet, "$notedPosition");
        Cell subscribed = findCell(sheet, "$subscribed");
        Cell subscribedName = findCell(sheet, "$subscribedName");
        Cell subscribedRank = findCell(sheet, "$subscribedRank");
        Cell subscribedPosition = findCell(sheet, "$subscribedPosition");

        examType.setCellValue(chemistry.getExamType());
        reportNo.setCellValue(chemistry.getReportNo());
        caseType.setCellValue(chemistry.getCaseType());
        suspects.setCellValue(chemistry.getSuspects());
        victims.setCellValue(chemistry.getVictims());
        timeDateReceived.setCellValue(chemistry.getTimeDateReceived());
        requestingParty.setCellValue(chemistry.getRequestingParty());
        specimenSubmitted.setCellValue(chemistry.getSpecimenSubmitted());
        purposeOfLabExam.setCellValue(chemistry.getPurposeOfLabExam());
        findings.setCellValue(chemistry.getFindings());
        conclusions.setCellValue(chemistry.getConclusions());
        remarks.setCellValue(chemistry.getRemarks());
        timeDateCompleted.setCellValue(chemistry.getTimeDateCompleted());
        examinerName.setCellValue(chemistry.getExaminerName());
        examinerRank.setCellValue(chemistry.getExaminerRank());
        examinerPosition.setCellValue(chemistry.getExaminerPosition());
        appName.setCellValue(chemistry.getAppName());
        appRank.setCellValue(chemistry.getAppRank());
        appPosition.setCellValue(chemistry.getAppPosition());
        notedName.setCellValue(chemistry.getNotedName());
        notedRank.setCellValue(chemistry.getNotedRank());
        notedPosition.setCellValue(chemistry.getNotedPosition());
        subscribed.setCellValue(chemistry.getSubscribed());
        subscribedName.setCellValue(chemistry.getSubscribedName());
        subscribedRank.setCellValue(chemistry.getSubscribedRank());
        subscribedPosition.setCellValue(chemistry.getSubscribedPosition());

        chemistryDAO.chemistryInfo(chemistry);

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

    }
    return wb;
}

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

@Override
public Workbook createMonthlyReport(HttpSession session, String month) {
    Workbook wb = null;/*from  w  ww  . j a  va2  s. co m*/

    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 .  ja va2  s.  c om

    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.DrugTestServiceImpl.java

@Override
public Workbook create(DrugTest drugTest, HttpSession session) {
    Workbook wb = null;/*from w w  w.  j av a2  s  . c  om*/

    try {
        InputStream inp = session.getServletContext().getResourceAsStream("/WEB-INF/templates/DrugTest.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);

        //iterate over keywords  
        Cell fadtNo = findCell(sheet, "$fadtNo");
        Cell sbrNo = findCell(sheet, "$sbrNo");
        Cell timeDate = findCell(sheet, "$timeDate");
        Cell name = findCell(sheet, "$name");
        Cell address = findCell(sheet, "$address");
        Cell age = findCell(sheet, "$age");
        Cell sex = findCell(sheet, "$sex");
        Cell purposeFL = findCell(sheet, "$purposeFL");
        Cell purposePTCFOR = findCell(sheet, "$purposePTCFOR");
        Cell specimenSubmitted = findCell(sheet, "$specimenSubmitted");
        Cell purposeOfExamination = findCell(sheet, "$purposeOfExamination");
        Cell methamphetamine = findCell(sheet, "$methamphetamine");
        Cell thc = findCell(sheet, "$thc");
        Cell remarks = findCell(sheet, "$remarks");
        Cell examinerName = findCell(sheet, "$examinerName");
        Cell examinerRank = findCell(sheet, "$examinerRank");
        Cell examinerPosition = findCell(sheet, "$examinerPosition");
        Cell appName = findCell(sheet, "$appName");
        Cell appRank = findCell(sheet, "$appRank");
        Cell appPosition = findCell(sheet, "$appPosition");

        //Modify the cellContents here
        // Write the output to a file
        //get from param
        fadtNo.setCellValue(drugTest.getFadtNo());
        sbrNo.setCellValue(drugTest.getSbrNo());
        timeDate.setCellValue(drugTest.getTimeDate());
        name.setCellValue(drugTest.getName());
        address.setCellValue(drugTest.getAddress());
        age.setCellValue(drugTest.getAge());
        sex.setCellValue(drugTest.getSex());

        switch (drugTest.getPurpose().trim()) {
        case "Firearm License":
            purposeFL.setCellValue("   ");
            purposePTCFOR.setCellValue("");
            break;

        case "Permit to Carry Firearms Outside Residence (PTCFOR)":
            purposeFL.setCellValue("");
            purposePTCFOR.setCellValue("   ");
            break;

        default:
            purposeFL.setCellValue("   ");
            purposePTCFOR.setCellValue("   ");
            break;
        }

        specimenSubmitted.setCellValue(drugTest.getSpecimenSubmitted());
        purposeOfExamination.setCellValue(drugTest.getPurposeOfExamination());
        methamphetamine.setCellValue(drugTest.getMethamphetamine());
        thc.setCellValue(drugTest.getThc());
        remarks.setCellValue(drugTest.getRemarks());
        examinerName.setCellValue(drugTest.getExaminerName());
        examinerRank.setCellValue(drugTest.getExaminerRank());
        examinerPosition.setCellValue(drugTest.getExaminerPosition());
        appName.setCellValue(drugTest.getAppName());
        appRank.setCellValue(drugTest.getAppRank());
        appPosition.setCellValue(drugTest.getAppPosition());

        drugTestDAO.drugTestInfo(drugTest);
    } catch (Exception e) {
        e.printStackTrace();

    }
    return wb;
}

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

@Override
public Workbook create(Firearms firearms, HttpSession session) {
    Workbook wb = null;//w w w  .j av  a2  s . c  o  m

    try {
        InputStream inp = session.getServletContext().getResourceAsStream("/WEB-INF/templates/Default.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);

        Cell division = findCell(sheet, "$division");
        Cell reportNo = findCell(sheet, "$reportNo");
        Cell caseType = findCell(sheet, "$caseType");
        Cell suspect = findCell(sheet, "$suspect");
        Cell victim = findCell(sheet, "$victim");
        Cell timeDateReceived = findCell(sheet, "$timeDateReceived");
        Cell requestingParty = findCell(sheet, "$requestingParty");
        Cell specimenSubmitted = findCell(sheet, "$specimenSubmitted");
        Cell purposeOfLabExam = findCell(sheet, "$purposeOfLabExam");
        Cell findings = findCell(sheet, "$findings");
        Cell conclusion = findCell(sheet, "$conclusion");
        Cell remarks = findCell(sheet, "$remarks");
        Cell timeDateCompleted = findCell(sheet, "$timeDateCompleted");
        Cell examinerName = findCell(sheet, "$examinerName");
        Cell examinerRank = findCell(sheet, "$examinerRank");
        Cell examinerPosition = findCell(sheet, "$examinerPosition");
        Cell notedName = findCell(sheet, "$notedName");
        Cell notedRank = findCell(sheet, "$notedRank");
        Cell notedPosition = findCell(sheet, "$notedPosition");

        division.setCellValue(firearms.getDivision());
        reportNo.setCellValue(firearms.getReportNo());
        caseType.setCellValue(firearms.getCaseType());
        suspect.setCellValue(firearms.getSuspect());
        victim.setCellValue(firearms.getVictim());
        timeDateReceived.setCellValue(firearms.getTimeDateReceived());
        requestingParty.setCellValue(firearms.getRequestingParty());
        specimenSubmitted.setCellValue(firearms.getSpecimenSubmitted());
        purposeOfLabExam.setCellValue(firearms.getPurposeOfLabExam());
        findings.setCellValue(firearms.getFindings());
        conclusion.setCellValue(firearms.getConclusion());
        remarks.setCellValue(firearms.getRemarks());
        timeDateCompleted.setCellValue(firearms.getTimeDateCompleted());
        examinerName.setCellValue(firearms.getExaminerName());
        examinerRank.setCellValue(firearms.getExaminerRank());
        examinerPosition.setCellValue(firearms.getExaminerPosition());
        notedName.setCellValue(firearms.getNotedName());
        notedRank.setCellValue(firearms.getNotedRank());
        notedPosition.setCellValue(firearms.getNotedPosition());
        firearmsDAO.firearmsInfo(firearms);
    } 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  w  w .ja v a  2  s.  c o m*/

    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.MacroEtchingServiceImpl.java

@Override
public Workbook create(MacroEtching macroEtching, HttpSession session) {
    Workbook wb = null;// w w w. jav  a2  s .  co  m
    try {
        InputStream inp = session.getServletContext().getResourceAsStream("/WEB-INF/templates/meCert.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);

        Cell dateCreated = findCell(sheet, "$dateCreated");
        Cell rclo = findCell(sheet, "$rclo");
        Cell make = findCell(sheet, "$make");
        Cell color = findCell(sheet, "$color");
        Cell plateNo = findCell(sheet, "$plateNo");
        Cell engineNo = findCell(sheet, "$engineNo");
        Cell chassisNo = findCell(sheet, "$chassisNo");
        Cell eNo = findCell(sheet, "$eNo");
        Cell cNo = findCell(sheet, "$cNo");
        Cell owner = findCell(sheet, "$owner");
        Cell address = findCell(sheet, "$address");
        Cell appName = findCell(sheet, "$appName");
        Cell appRank = findCell(sheet, "$appRank");
        Cell appPosition = findCell(sheet, "$appPosition");
        Cell examinerName = findCell(sheet, "$examinerName");
        Cell examinerRank = findCell(sheet, "$examinerRank");
        Cell examinerPosition = findCell(sheet, "$examinerPosition");

        dateCreated.setCellValue(macroEtching.getDateCreated());
        rclo.setCellValue(macroEtching.getRclo());
        make.setCellValue(macroEtching.getMake());
        color.setCellValue(macroEtching.getColor());
        plateNo.setCellValue(macroEtching.getPlateNo());
        engineNo.setCellValue(macroEtching.getEngineNo());
        chassisNo.setCellValue(macroEtching.getChassisNo());
        eNo.setCellValue(macroEtching.getEngineNo());
        cNo.setCellValue(macroEtching.getChassisNo());
        owner.setCellValue(macroEtching.getOwner());
        address.setCellValue(macroEtching.getAddress());
        appName.setCellValue(macroEtching.getAppName());
        appRank.setCellValue(macroEtching.getAppRank());
        appPosition.setCellValue(macroEtching.getAppPosition());
        examinerName.setCellValue(macroEtching.getExaminerName());
        examinerRank.setCellValue(macroEtching.getExaminerRank());
        examinerPosition.setCellValue(macroEtching.getExaminerPosition());

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

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

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

    try {
        InputStream inp = session.getServletContext().getResourceAsStream("/WEB-INF/templates/Default.xls");
        wb = WorkbookFactory.create(inp);
        Sheet sheet = wb.getSheetAt(0);

        Cell division = findCell(sheet, "$division");
        Cell reportNo = findCell(sheet, "$reportNo");
        Cell caseType = findCell(sheet, "$caseType");
        Cell suspect = findCell(sheet, "$suspect");
        Cell victim = findCell(sheet, "$victim");
        Cell timeDateReceived = findCell(sheet, "$timeDateReceived");
        Cell requestingParty = findCell(sheet, "$requestingParty");
        Cell specimenSubmitted = findCell(sheet, "$specimenSubmitted");
        Cell purposeOfLabExam = findCell(sheet, "$purposeOfLabExam");
        Cell findings = findCell(sheet, "$findings");
        Cell conclusion = findCell(sheet, "$conclusion");
        Cell remarks = findCell(sheet, "$remarks");
        Cell timeDateCompleted = findCell(sheet, "$timeDateCompleted");
        Cell examinerName = findCell(sheet, "$examinerName");
        Cell examinerRank = findCell(sheet, "$examinerRank");
        Cell examinerPosition = findCell(sheet, "$examinerPosition");
        Cell notedName = findCell(sheet, "$notedName");
        Cell notedRank = findCell(sheet, "$notedRank");
        Cell notedPosition = findCell(sheet, "$notedPosition");

        division.setCellValue(medicoLegal.getDivision());
        reportNo.setCellValue(medicoLegal.getReportNo());
        caseType.setCellValue(medicoLegal.getCaseType());
        suspect.setCellValue(medicoLegal.getSuspect());
        victim.setCellValue(medicoLegal.getVictim());
        timeDateReceived.setCellValue(medicoLegal.getTimeDateReceived());
        requestingParty.setCellValue(medicoLegal.getRequestingParty());
        specimenSubmitted.setCellValue(medicoLegal.getSpecimenSubmitted());
        purposeOfLabExam.setCellValue(medicoLegal.getPurposeOfLabExam());
        findings.setCellValue(medicoLegal.getFindings());
        conclusion.setCellValue(medicoLegal.getConclusion());
        remarks.setCellValue(medicoLegal.getRemarks());
        timeDateCompleted.setCellValue(medicoLegal.getTimeDateCompleted());
        examinerName.setCellValue(medicoLegal.getExaminerName());
        examinerRank.setCellValue(medicoLegal.getExaminerRank());
        examinerPosition.setCellValue(medicoLegal.getExaminerPosition());
        notedName.setCellValue(medicoLegal.getNotedName());
        notedRank.setCellValue(medicoLegal.getNotedRank());
        notedPosition.setCellValue(medicoLegal.getNotedPosition());

        medicoLegalDAO.medicoLegalInfo(medicoLegal);
    } 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;/* w  w  w .  ja  va  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;
}