List of usage examples for org.apache.poi.xssf.usermodel XSSFCell setCellValue
@Override public void setCellValue(boolean value)
From source file:uscraper.UScraper.java
public static void CareerBuilderScraper(String path, int totalPage, String[] states) { setLoggerOff();//from w w w .j a v a 2s .com try { outstream = new FileOutputStream(new File(path)); workbook = new XSSFWorkbook(); sheet = workbook.createSheet("CareerBuilder"); webClient = new WebClient(); webClient.getOptions().setJavaScriptEnabled(false); webClient.getOptions().setTimeout(86400000);// 1 day page = webClient.getPage("http://www.careerbuilder.com/"); HtmlForm form = page.getFirstByXPath("//form[@action='http://www.careerbuilder.com/jobs']"); HtmlElement button = (HtmlElement) page.createElement("button"); button.setAttribute("type", "submit"); form.appendChild(button); HtmlTextInput what = (HtmlTextInput) page.getElementByName("keywords"); HtmlTextInput where = (HtmlTextInput) page.getElementByName("location"); what.setValueAttribute(""); for (String state : states) { where.setValueAttribute(state); //where.setValueAttribute("Connecticut"); //System.out.println(page.asXml());System.exit(0); page = button.click(); webClient.waitForBackgroundJavaScript(1000); int pageNum = 1; int rowNum = 0; while (pageNum <= totalPage) { List<?> aTitle = page.getByXPath("//div[@class='job-row']/div/div/h2/a"); for (int i = 0; i < aTitle.size(); i++) { HtmlAnchor a = (HtmlAnchor) aTitle.get(i); XSSFRow row = (XSSFRow) sheet.createRow(rowNum); XSSFCell cellSource = row.createCell(0); cellSource.setCellValue("CareerBuilder"); XSSFCell cellTitle = row.createCell(1); cellTitle.setCellValue(a.asText()); HtmlPage descriptionPage = a.click(); webClient.waitForBackgroundJavaScript(1000); HtmlDivision div = (HtmlDivision) descriptionPage.getByXPath("//div[@class='description']") .get(0); XSSFCell cellDesc = row.createCell(8); cellDesc.setCellValue(div.asText()); rowNum++; } webClient.waitForBackgroundJavaScript(1000); List<?> hCompany = page.getByXPath( "//div[@class='job-row']/div/div[@class='columns large-2 medium-3 small-12']/h4"); rowNum = 0; for (int i = 0; i < hCompany.size(); i++) { HtmlElement e = (HtmlElement) hCompany.get(i); XSSFRow row = (XSSFRow) sheet.getRow(rowNum); XSSFCell cellCompany = row.createCell(2); cellCompany.setCellValue(e.asText()); rowNum++; } webClient.waitForBackgroundJavaScript(1000); List<?> hLocation = page.getByXPath( "//div[@class='job-row']/div[@class='row job-information']/div[@class='columns end large-2 medium-3 small-12']/h4[@class='job-text']"); rowNum = 0; for (int i = 0; i < hLocation.size(); i++) { HtmlElement e = (HtmlElement) hLocation.get(i); XSSFRow row = (XSSFRow) sheet.getRow(rowNum); XSSFCell cellLocation = row.createCell(3); cellLocation.setCellValue(e.asText()); System.out.println(row.getCell(3)); rowNum++; } webClient.waitForBackgroundJavaScript(1000); List<?> hInfo = page .getByXPath("//div[@class='job-row']/div/div[@class='columns medium-6 large-8']/h4"); rowNum = 0; for (int i = 0; i < hInfo.size(); i++) { HtmlElement e = (HtmlElement) hInfo.get(i); XSSFRow row = (XSSFRow) sheet.getRow(rowNum); XSSFCell cellInfo = row.createCell(4); cellInfo.setCellValue(e.asText()); rowNum++; } webClient.waitForBackgroundJavaScript(1000); List<?> emElapsedTime = page .getByXPath("//div[@class='job-row']/div/div/div[@class='show-for-medium-up']/em"); rowNum = 0; for (int i = 0; i < emElapsedTime.size(); i++) { HtmlElement e = (HtmlElement) emElapsedTime.get(i); XSSFRow row = (XSSFRow) sheet.getRow(rowNum); XSSFCell cellElapsedTime = row.createCell(5); cellElapsedTime.setCellValue(e.asText()); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss") .format(Calendar.getInstance().getTime()); XSSFCell cellDateTime = row.createCell(6); cellDateTime.setCellValue(timeStamp); XSSFCell cellState = row.createCell(7); cellState.setCellValue(state); rowNum++; } HtmlAnchor next = (HtmlAnchor) page.getElementById("next-button"); next.click(); pageNum++; } } workbook.write(outstream); } catch (Exception e) { e.printStackTrace(); } finally { try { if (workbook != null) workbook.close(); if (outstream != null) outstream.close(); } catch (Exception e) { e.printStackTrace(); } } return; }
From source file:vd10_workbook.AbilityManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("kha_nang"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Kh nng lm vic"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 2 //last column (0-based) );//from www .jav a2s.c om sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border this.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); this.setThickBorder(cell, workbook); this.setBackGroundColor(cell, workbook); //ID_NHAN_VIEN sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("ID Nhn vin"); this.setThickBorder(cell, workbook); this.setBackGroundColor(cell, workbook); //ID_NGOAI_NGU sheet.setColumnWidth(2, 5000); cell = (XSSFCell) row.createCell((short) 2); cell.setCellValue("ID Ngoi ng"); this.setThickBorder(cell, workbook); this.setBackGroundColor(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); this.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); this.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getEmployeeID()); cell = (XSSFCell) row.createCell((short) 2); this.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getLanguageID()); } }
From source file:vd10_workbook.AssignedVoteManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("phieu_phan_cong"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Phiu phn cng"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 4 //last column (0-based) );// www . j a v a2 s. com sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); //Ngy bt u sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("Ngy bt u"); AbilityManagement.setThickBorder(cell, workbook); //S ngy sheet.setColumnWidth(2, 5000); cell = (XSSFCell) row.createCell((short) 2); cell.setCellValue("S ngy"); AbilityManagement.setThickBorder(cell, workbook); //ID nhn vin sheet.setColumnWidth(3, 5000); cell = (XSSFCell) row.createCell((short) 3); cell.setCellValue("ID nhn vin"); AbilityManagement.setThickBorder(cell, workbook); //ID loi cng vic sheet.setColumnWidth(4, 5000); cell = (XSSFCell) row.createCell((short) 4); cell.setCellValue("ID loi cng vic"); AbilityManagement.setThickBorder(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getStartDate().toString()); cell = (XSSFCell) row.createCell((short) 2); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getNumberOfdate()); cell = (XSSFCell) row.createCell((short) 3); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getEmployeeID()); cell = (XSSFCell) row.createCell((short) 4); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getWorkTypeID()); } //== calculate sum of days ==// row = sheet.createRow((short) startRow + 2 + this.list.size()); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Tng"); //merge cells at column 1 & 2 cellRangeAddress = new CellRangeAddress(startRow + 2 + this.list.size(), //first row (0-based) startRow + 2 + this.list.size(), //last row (0-based) 0, //first column (0-based) 1 //last column (0-based) ); sheet.addMergedRegion(cellRangeAddress); //set border RegionUtil.setBorderBottom(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); RegionUtil.setBorderRight(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); RegionUtil.setBorderTop(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); RegionUtil.setBorderLeft(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); cell = row.createCell((short) 2); cell.setCellFormula("SUM(C" + (startRow + 1 + 2) + ":C" + (startRow + 2 + this.list.size()) + ")"); AbilityManagement.setThickBorder(cell, workbook); }
From source file:vd10_workbook.Company.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("cong_ty"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Thng tin cng ty"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 5 //last column (0-based) );// w w w.j a v a 2 s.c o m sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border // AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); //Tn cng ty sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("Tn"); AbilityManagement.setThickBorder(cell, workbook); //?in thoi sheet.setColumnWidth(2, 5000); cell = (XSSFCell) row.createCell((short) 2); cell.setCellValue("?in thoi"); AbilityManagement.setThickBorder(cell, workbook); //?a ch sheet.setColumnWidth(3, 10000); cell = (XSSFCell) row.createCell((short) 3); cell.setCellValue("?a ch"); AbilityManagement.setThickBorder(cell, workbook); //Tui ti thiu sheet.setColumnWidth(4, 5000); cell = (XSSFCell) row.createCell((short) 4); cell.setCellValue("Tui ti thiu"); AbilityManagement.setThickBorder(cell, workbook); //Tui ti a sheet.setColumnWidth(5, 5000); cell = (XSSFCell) row.createCell((short) 5); cell.setCellValue("Tui ti a"); AbilityManagement.setThickBorder(cell, workbook); //== fill out the information ==// row = sheet.createRow((short) startRow + 2); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(1); //== content ==// //Tn cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.name); //?in thoi cell = (XSSFCell) row.createCell((short) 2); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.phoneNumber); //?a ch cell = (XSSFCell) row.createCell((short) 3); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.address); //Tui ti thiu cell = (XSSFCell) row.createCell((short) 4); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.minAge); //Tui ti a cell = (XSSFCell) row.createCell((short) 5); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.maxAge); }
From source file:vd10_workbook.DepartmentManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("don_vi"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("?n v"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 1 //last column (0-based) );//w ww .j a v a2 s.c o m sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); //Tn n v sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("Tn n v"); AbilityManagement.setThickBorder(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getName().toString()); } }
From source file:vd10_workbook.EmployeeManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("ds_nhan_vien"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Danh sch nhn vin"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 7 //last column (0-based) );/*from w w w.ja v a 2 s . c om*/ sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); //H? tn sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("H? tn"); AbilityManagement.setThickBorder(cell, workbook); //Gii tnh sheet.setColumnWidth(2, 5000); cell = (XSSFCell) row.createCell((short) 2); cell.setCellValue("Gii tnh"); AbilityManagement.setThickBorder(cell, workbook); //Ngy sinh sheet.setColumnWidth(3, 5000); cell = (XSSFCell) row.createCell((short) 3); cell.setCellValue("Ngy sinh"); AbilityManagement.setThickBorder(cell, workbook); //CMND sheet.setColumnWidth(4, 5000); cell = (XSSFCell) row.createCell((short) 4); cell.setCellValue("CMND"); AbilityManagement.setThickBorder(cell, workbook); //Mc lng sheet.setColumnWidth(5, 5000); cell = (XSSFCell) row.createCell((short) 5); cell.setCellValue("Mc lng"); AbilityManagement.setThickBorder(cell, workbook); //?a ch sheet.setColumnWidth(6, 10000); cell = (XSSFCell) row.createCell((short) 6); cell.setCellValue("?a ch"); AbilityManagement.setThickBorder(cell, workbook); //?n v sheet.setColumnWidth(7, 2000); cell = (XSSFCell) row.createCell((short) 7); cell.setCellValue("?n v"); AbilityManagement.setThickBorder(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getName().toString()); cell = (XSSFCell) row.createCell((short) 2); AbilityManagement.setThinBorder(cell, workbook); if (this.list.get(i).getSex() == 1) { cell.setCellValue("Nam"); } else { cell.setCellValue("N"); } cell = (XSSFCell) row.createCell((short) 3); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getDateOfbirth().toString()); cell = (XSSFCell) row.createCell((short) 4); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getIdentityNumber().toString()); cell = (XSSFCell) row.createCell((short) 5); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getSalary()); cell = (XSSFCell) row.createCell((short) 6); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getAddress()); cell = (XSSFCell) row.createCell((short) 7); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getDepartmentID()); } //== calculate sum of days ==// row = sheet.createRow((short) startRow + 2 + this.list.size()); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("S nhn vin c lng >= 6tr "); //merge cells at column 1 & 2 cellRangeAddress = new CellRangeAddress(startRow + 2 + this.list.size(), //first row (0-based) startRow + 2 + this.list.size(), //last row (0-based) 0, //first column (0-based) 1 //last column (0-based) ); sheet.addMergedRegion(cellRangeAddress); //set border RegionUtil.setBorderBottom(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); RegionUtil.setBorderRight(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); RegionUtil.setBorderTop(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); RegionUtil.setBorderLeft(XSSFCellStyle.BORDER_MEDIUM, cellRangeAddress, sheet, workbook); cell = row.createCell((short) 2); cell.setCellFormula( "COUNTIF(F" + (startRow + 1 + 2) + ":F" + (startRow + 2 + this.list.size()) + ",\">= 6000000\")"); AbilityManagement.setThickBorder(cell, workbook); }
From source file:vd10_workbook.ForeignLanguageManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("ngoai_ngu"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Ngoi ng"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 1 //last column (0-based) );/* w ww .j a v a 2s.c om*/ sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); //Tn ngn ng sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("Ngn ng"); AbilityManagement.setThickBorder(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getName().toString()); } }
From source file:vd10_workbook.RequirementManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("yeu_cau"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Bng yu cu"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 2 //last column (0-based) );/*from w w w . j a v a 2 s. c o m*/ sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); AbilityManagement.setBackGroundColor(cell, workbook); //ID loi cng vic sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("ID Loi cng vic"); AbilityManagement.setThickBorder(cell, workbook); AbilityManagement.setBackGroundColor(cell, workbook); //ID ngoi ng sheet.setColumnWidth(2, 5000); cell = (XSSFCell) row.createCell((short) 2); cell.setCellValue("ID Ngoi ng"); AbilityManagement.setThickBorder(cell, workbook); AbilityManagement.setBackGroundColor(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getWorktypeID()); cell = (XSSFCell) row.createCell((short) 2); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getForeignLanguageID()); } }
From source file:vd10_workbook.UserGroupManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("nhom_nguoi_dung"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Nhm ng?i dng"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 2 //last column (0-based) );/* w w w. java 2 s . c o m*/ sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); AbilityManagement.setBackGroundColor(cell, workbook); //Tn nhn vin sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("Tn nhn vin"); AbilityManagement.setThickBorder(cell, workbook); AbilityManagement.setBackGroundColor(cell, workbook); //m s sheet.setColumnWidth(2, 5000); cell = (XSSFCell) row.createCell((short) 2); cell.setCellValue("M s nhm"); AbilityManagement.setThickBorder(cell, workbook); AbilityManagement.setBackGroundColor(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getName()); cell = (XSSFCell) row.createCell((short) 2); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getId()); } }
From source file:vd10_workbook.UserManagement.java
public void createWorkSheet(XSSFWorkbook workbook) { XSSFSheet sheet = workbook.createSheet("nguoi_dung"); int startRow = 0; XSSFRow row = sheet.createRow((short) startRow); //== THE TITLE ==// //SET HEIGHT OF ROW 2 (in excel) row.setHeight((short) 500); XSSFCell cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("Danh sch ng?i dng"); //MEARGING CELLS //this statement for merging cells CellRangeAddress cellRangeAddress = new CellRangeAddress(startRow, //first row (0-based) startRow, //last row (0-based) 0, //first column (0-based) 4 //last column (0-based) );//www.j a v a 2s . c o m sheet.addMergedRegion(cellRangeAddress); // Center Align Cell Contents XSSFCellStyle align = workbook.createCellStyle(); align.setAlignment(XSSFCellStyle.ALIGN_CENTER); align.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); cell.setCellStyle(align); //set border AbilityManagement.setRegionBoder(cellRangeAddress, workbook, sheet); //==THE LABELS ==// //STT row = sheet.createRow((short) startRow + 1); row.setHeight((short) 400); cell = (XSSFCell) row.createCell((short) 0); cell.setCellValue("STT"); AbilityManagement.setThickBorder(cell, workbook); //Tn ng?i dng sheet.setColumnWidth(1, 5000); cell = (XSSFCell) row.createCell((short) 1); cell.setCellValue("Tn"); AbilityManagement.setThickBorder(cell, workbook); //Mt khu sheet.setColumnWidth(2, 5000); cell = (XSSFCell) row.createCell((short) 2); cell.setCellValue("Mt khu"); AbilityManagement.setThickBorder(cell, workbook); //M rng sheet.setColumnWidth(3, 5000); cell = (XSSFCell) row.createCell((short) 3); cell.setCellValue("M rng"); AbilityManagement.setThickBorder(cell, workbook); //ID_NHOM_NGUOI_DUNG sheet.setColumnWidth(4, 5000); cell = (XSSFCell) row.createCell((short) 4); cell.setCellValue("ID Nhm ng?i dng"); AbilityManagement.setThickBorder(cell, workbook); //fill out the rows for (int i = 0; i < this.list.size(); i++) { row = sheet.createRow((short) startRow + 2 + i); cell = (XSSFCell) row.createCell((short) 0); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(i + 1); cell = (XSSFCell) row.createCell((short) 1); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getName().toString()); cell = (XSSFCell) row.createCell((short) 2); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getPassword()); cell = (XSSFCell) row.createCell((short) 3); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getExpansion()); cell = (XSSFCell) row.createCell((short) 4); AbilityManagement.setThinBorder(cell, workbook); cell.setCellValue(this.list.get(i).getGroupID()); } }