List of usage examples for org.apache.poi.ss.usermodel Cell setCellValue
void setCellValue(boolean value);
From source file:com.crimelab.service.CriminalServiceImpl.java
@Override public Workbook createTenprintsCards(HttpSession session, String month) { Workbook wb = null;/* ww w .jav a 2 s . co 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.DrugTestServiceImpl.java
@Override public Workbook create(DrugTest drugTest, HttpSession session) { Workbook wb = null;/* w w w .j a v a2s .c o m*/ 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;//from w w w. j a va 2 s. c om 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 ww w. j a va2 s .co 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;//from ww w.j a v a2s .c o 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 w ww. ja v 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(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;/*from w w w . ja v a2 s .c o m*/ 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; }
From source file:com.crimelab.service.PiServiceImpl.java
@Override public Workbook create(PiReport piReport, HttpSession session) { Workbook wb = null;//from ww w . j av a2 s . co m try { InputStream inp = session.getServletContext().getResourceAsStream("/WEB-INF/templates/Default.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"); examType.setCellValue(piReport.getExamType()); reportNo.setCellValue(piReport.getReportNo()); caseType.setCellValue(piReport.getCaseType()); suspects.setCellValue(piReport.getSuspects()); victims.setCellValue(piReport.getVictims()); timeDateReceived.setCellValue(piReport.getTimeDateReceived()); requestingParty.setCellValue(piReport.getRequestingParty()); specimenSubmitted.setCellValue(piReport.getSpecimenSubmitted()); purposeOfLabExam.setCellValue(piReport.getPurposeOfLabExam()); findings.setCellValue(piReport.getFindings()); conclusions.setCellValue(piReport.getConclusions()); remarks.setCellValue(piReport.getRemarks()); timeDateCompleted.setCellValue(piReport.getTimeDateCompleted()); examinerName.setCellValue(piReport.getExaminerName()); examinerRank.setCellValue(piReport.getExaminerRank()); examinerPosition.setCellValue(piReport.getExaminerPosition()); appName.setCellValue(piReport.getAppName()); appRank.setCellValue(piReport.getAppRank()); appPosition.setCellValue(piReport.getAppPosition()); notedName.setCellValue(piReport.getNotedName()); notedRank.setCellValue(piReport.getNotedRank()); notedPosition.setCellValue(piReport.getNotedPosition()); piDAO.piReportInfo(piReport); } catch (Exception e) { e.printStackTrace(); } return wb; }
From source file:com.crimelab.service.QdServiceImpl.java
@Override public Workbook create(Qd qd, HttpSession session) { Workbook wb = null;//from 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(qd.getDivision()); reportNo.setCellValue(qd.getReportNo()); caseType.setCellValue(qd.getCaseType()); suspect.setCellValue(qd.getSuspect()); victim.setCellValue(qd.getVictim()); timeDateReceived.setCellValue(qd.getTimeDateReceived()); requestingParty.setCellValue(qd.getRequestingParty()); specimenSubmitted.setCellValue(qd.getSpecimenSubmitted()); purposeOfLabExam.setCellValue(qd.getPurposeOfLabExam()); findings.setCellValue(qd.getFindings()); conclusion.setCellValue(qd.getConclusion()); remarks.setCellValue(qd.getRemarks()); timeDateCompleted.setCellValue(qd.getTimeDateCompleted()); examinerName.setCellValue(qd.getExaminerName()); examinerRank.setCellValue(qd.getExaminerRank()); examinerPosition.setCellValue(qd.getExaminerPosition()); notedName.setCellValue(qd.getNotedName()); notedRank.setCellValue(qd.getNotedRank()); notedPosition.setCellValue(qd.getNotedPosition()); qdDAO.qdInfo(qd); } catch (Exception e) { e.printStackTrace(); } return wb; }
From source file:com.crm.webapp.util.ExcelCustomExporter.java
License:Apache License
@Override public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle, boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor, boolean subTable) throws IOException { wb = new XSSFWorkbook(); String safeName = WorkbookUtil.createSafeSheetName(filename); Sheet sheet = wb.createSheet(safeName); cellStyle = wb.createCellStyle();//w w w .java2s. c o m facetStyle = wb.createCellStyle(); titleStyle = wb.createCellStyle(); createCustomFonts(); int maxColumns = 0; StringTokenizer st = new StringTokenizer(tableId, ","); while (st.hasMoreElements()) { String tableName = (String) st.nextElement(); UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(), tableName); if (component == null) { throw new FacesException("Cannot find component \"" + tableName + "\" in view."); } if (!(component instanceof DataTable || component instanceof DataList)) { throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName() + "\", exporter must target a PrimeFaces DataTable/DataList."); } DataList list = null; DataTable table = null; int cols = 0; if (preProcessor != null) { preProcessor.invoke(context.getELContext(), new Object[] { wb }); } if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) { Row titleRow = sheet.createRow(sheet.getLastRowNum()); int cellIndex = titleRow.getLastCellNum() == -1 ? 0 : titleRow.getLastCellNum(); Cell cell = titleRow.createCell(cellIndex); cell.setCellValue(new XSSFRichTextString(tableTitle)); Font titleFont = wb.createFont(); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); titleStyle.setFont(titleFont); cell.setCellStyle(titleStyle); sheet.createRow(sheet.getLastRowNum() + 3); } if (component instanceof DataList) { list = (DataList) component; if (list.getHeader() != null) { tableFacet(context, sheet, list, "header"); } if (pageOnly) { exportPageOnly(context, list, sheet); } else { exportAll(context, list, sheet); } cols = list.getRowCount(); } else { table = (DataTable) component; int columnsCount = getColumnsCount(table); if (table.getHeader() != null && !subTable) { tableFacet(context, sheet, table, columnsCount, "header"); } if (!subTable) { tableColumnGroup(sheet, table, "header"); } addColumnFacets(table, sheet, ColumnType.HEADER); if (pageOnly) { exportPageOnly(context, table, sheet); } else if (selectionOnly) { exportSelectionOnly(context, table, sheet); } else { exportAll(context, table, sheet, subTable); } if (table.hasFooterColumn() && !subTable) { addColumnFacets(table, sheet, ColumnType.FOOTER); } if (!subTable) { tableColumnGroup(sheet, table, "footer"); } table.setRowIndex(-1); if (postProcessor != null) { postProcessor.invoke(context.getELContext(), new Object[] { wb }); } cols = table.getColumnsCount(); if (maxColumns < cols) { maxColumns = cols; } } sheet.createRow(sheet.getLastRowNum() + Integer.parseInt(datasetPadding)); } if (!subTable) for (int i = 0; i < maxColumns; i++) { sheet.autoSizeColumn((short) i); } PrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(true); printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE); sheet.setPrintGridlines(true); writeExcelToResponse(context.getExternalContext(), wb, filename); }