List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet getRow
@Override public HSSFRow getRow(int rowIndex)
From source file:DomainToolCore.Report.XLSSubDomains.java
License:Open Source License
private void WriteSubDomain(HSSFSheet firstSheet) { firstSheet.createRow(5).createCell(0).setCellValue("SubDomain"); firstSheet.getRow(5).getCell(0).setCellStyle(setBold()); firstSheet.setColumnWidth(0, 10000); for (int i = 1, j = 6; i < subdxls.size(); i++) { firstSheet.createRow(j).createCell(0).setCellValue((String) subdxls.get(i)); j++;//from w ww . ja v a 2 s . c o m } }
From source file:DomainToolCore.Report.XLSSubDomains.java
License:Open Source License
private void WriteIp(HSSFSheet sheet) { sheet.getRow(5).createCell(1).setCellValue("IP Address"); sheet.getRow(5).getCell(1).setCellStyle(setBold()); sheet.setColumnWidth(1, 10000);/*from w w w. j a v a 2s .c om*/ for (int i = 1, j = 6; i < subdxls.size(); i++) { sheet.getRow(j).createCell(1).setCellValue((String) ipxls.get(i)); j++; } }
From source file:DomainToolCore.Report.XLSSubDomains.java
License:Open Source License
private void GeneratedBy(HSSFSheet sheet1) { int casella = subdxls.size() + 10; sheet1.createRow(casella).createCell(0).setCellValue("Generated by Domain Tool on " + c.get(Calendar.DAY_OF_MONTH) + "/" + c.get(Calendar.MONTH) + "/" + c.get(Calendar.YEAR)); sheet1.getRow(casella).getCell(0).setCellStyle(BackColor()); }
From source file:eafit.cdei.asignacion.input.ReadCurrentCourses.java
public List<Teacher> loadCurrentOffering() throws Exception { try {// w ww . j a va 2s .c om FileInputStream fileInputStream = new FileInputStream("current_classes.xls"); HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream); HSSFSheet worksheet = workbook.getSheet("currentOffering"); boolean keepDoing = true; for (int i = 0; i < worksheet.getLastRowNum() + 1; i++) { HSSFRow row1 = worksheet.getRow(i); HSSFCell cellF1 = row1.getCell((short) 5); String f1Val = ((int) cellF1.getNumericCellValue()) + ""; HSSFCell cellW1 = row1.getCell((short) 22); String w1Val = cellW1.getStringCellValue(); HSSFCell cellX1 = row1.getCell((short) 23); String x1Val = cellX1.getStringCellValue(); HSSFCell cellY1 = row1.getCell((short) 24); String y1Val = cellY1.getStringCellValue(); HSSFCell cellAU1 = row1.getCell((short) 46); String au1Val = ((int) cellAU1.getNumericCellValue()) + ""; HSSFCell cellAW1 = row1.getCell((short) 48); String aw1Val = cellAW1.getStringCellValue(); if (f1Val == null || f1Val.length() == 0 || f1Val.equals("0")) { keepDoing = false; } Course c = new Course(); c.setHourStart(f1Val); c.setHourEnd(au1Val); c.setDowList(generateDaysList(aw1Val)); c.setNameCourse(x1Val); c.setCodeCourse(w1Val); c.setCodeCourse(y1Val); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HHmm"); if (au1Val.length() == 3) { au1Val = "0" + au1Val; } if (f1Val.length() == 3) { f1Val = "0" + f1Val; } c.setHourEndLocal(LocalTime.parse(au1Val, dtf)); c.setHourStartLocal(LocalTime.parse(f1Val, dtf)); c.setDateStartLocal(LocalTime.parse(au1Val, dtf)); c.setDateEndLocal(LocalTime.parse(aw1Val, dtf)); System.out.println(c); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:eafit.cdei.asignacion.input.ReadCurrentOffering.java
public List<Teacher> loadCurrentOffering() throws Exception { try {/*from w ww .ja va 2 s. co m*/ FileInputStream fileInputStream = new FileInputStream("currentOffering.xls"); HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream); HSSFSheet worksheet = workbook.getSheet("currentOffering"); boolean keepDoing = true; for (int i = 0; i < worksheet.getLastRowNum() + 1; i++) { HSSFRow row1 = worksheet.getRow(i); HSSFCell cellF1 = row1.getCell((short) 5); String f1Val = ((int) cellF1.getNumericCellValue()) + ""; HSSFCell cellW1 = row1.getCell((short) 22); String w1Val = cellW1.getStringCellValue(); HSSFCell cellX1 = row1.getCell((short) 23); String x1Val = cellX1.getStringCellValue(); HSSFCell cellY1 = row1.getCell((short) 24); String y1Val = cellY1.getStringCellValue(); HSSFCell cellAU1 = row1.getCell((short) 46); String au1Val = ((int) cellAU1.getNumericCellValue()) + ""; HSSFCell cellAW1 = row1.getCell((short) 48); String aw1Val = cellAW1.getStringCellValue(); HSSFCell cellAB = row1.getCell((short) 27); String abVal = cellAB.getStringCellValue(); HSSFCell cellAC = row1.getCell((short) 28); String acVal = cellAC.getStringCellValue(); if (f1Val == null || f1Val.length() == 0 || f1Val.equals("0")) { keepDoing = false; } Course c = new Course(); c.setHourStart(f1Val); c.setHourEnd(au1Val); c.setDowList(generateDaysList(aw1Val)); c.setNameCourse(x1Val); c.setCodeCourse(w1Val); c.setCodeCourse(y1Val); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HHmm"); if (au1Val.length() == 3) { au1Val = "0" + au1Val; } if (f1Val.length() == 3) { f1Val = "0" + f1Val; } c.setHourEndLocal(LocalTime.parse(au1Val, dtf)); c.setHourStartLocal(LocalTime.parse(f1Val, dtf)); DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("yyyyMMdd"); //c.setDateStart(LocalDate.parse(abVal,dtf1)); //c.setHourStartLocal(LocalTime.parse(f1Val,dtf)); System.out.println(c); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
@Override public List<Teacher> loadTeacherAvailability() throws Exception { try {//from www. j ava2 s . c o m FileInputStream fileInputStream = new FileInputStream("googleDoc.xls"); HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream); HSSFSheet worksheet = workbook.getSheet("Form Responses 1"); boolean keepDoing = true; for (int i = 1; i < worksheet.getLastRowNum() + 1; i++) { HSSFRow row1 = worksheet.getRow(i); HSSFCell cellB1 = row1.getCell((short) 1); String b1Val = cellB1.getStringCellValue() + ""; HSSFCell cellG1 = row1.getCell((short) 6); String g1Val = cellG1.getStringCellValue() + ""; HSSFCell cellH1 = row1.getCell((short) 7); String h1Val = cellH1.getStringCellValue() + ""; HSSFCell cellJ1 = row1.getCell((short) 8); String j1Val = cellJ1.getStringCellValue() + ""; HSSFCell cellK1 = row1.getCell((short) 9); String k1Val = cellK1.getStringCellValue() + ""; HSSFCell cellI1 = row1.getCell((short) 10); String i1Val = cellI1.getStringCellValue() + ""; HSSFCell cellL1 = row1.getCell((short) 11); String l1Val = cellL1.getStringCellValue() + ""; HSSFCell cellM1 = row1.getCell((short) 12); String m1Val = cellM1.getStringCellValue() + ""; HSSFCell cellN1 = row1.getCell((short) 13); String n1Val = cellN1.getStringCellValue() + ""; HSSFCell cellO1 = row1.getCell((short) 14); String o1Val = cellO1.getStringCellValue() + ""; HSSFCell cellP1 = row1.getCell((short) 15); String p1Val = cellP1.getStringCellValue() + ""; HSSFCell cellQ1 = row1.getCell((short) 16); String q1Val = cellQ1.getStringCellValue() + ""; HSSFCell cellR1 = row1.getCell((short) 17); String r1Val = cellR1.getStringCellValue() + ""; HSSFCell cellS1 = row1.getCell((short) 18); String s1Val = cellS1.getStringCellValue() + ""; HSSFCell cellT1 = row1.getCell((short) 19); String t1Val = cellT1.getStringCellValue() + ""; HSSFCell cellU1 = row1.getCell((short) 20); String u1Val = cellU1.getStringCellValue() + ""; HSSFCell cellV1 = row1.getCell((short) 21); String v1Val = cellV1.getStringCellValue() + ""; HSSFCell cellW1 = row1.getCell((short) 22); String w1Val = cellW1.getStringCellValue() + ""; HSSFCell cellX1 = row1.getCell((short) 23); String x1Val = cellX1.getStringCellValue() + ""; HSSFCell cellY1 = row1.getCell((short) 24); String y1Val = cellY1.getStringCellValue() + ""; HSSFCell cellZ1 = row1.getCell((short) 25); String z1Val = cellZ1.getStringCellValue() + ""; HSSFCell cellAA1 = row1.getCell((short) 26); String aa1Val = cellAA1.getStringCellValue() + ""; HSSFCell cellAB1 = row1.getCell((short) 27); String ab1Val = cellAB1.getStringCellValue() + ""; if (b1Val.length() == 0) { keepDoing = false; } else { Teacher t = new Teacher(); t.setFullName(b1Val); t.addCourseAvaliability(generateMTF(getAnswer(g1Val), "06", "08")); t.addCourseAvaliability(generateMTF(getAnswer(h1Val), "08", "10")); t.addCourseAvaliability(generateMTF(getAnswer(i1Val), "10", "12")); t.addCourseAvaliability(generateMTF(getAnswer(j1Val), "12", "14")); t.addCourseAvaliability(generateMTF(getAnswer(k1Val), "14", "16")); t.addCourseAvaliability(generateMWF(getAnswer(l1Val), "06", "08")); t.addCourseAvaliability(generateMWF(getAnswer(n1Val), "08", "10")); t.addCourseAvaliability(generateMWF(getAnswer(m1Val), "10", "12")); t.addCourseAvaliability(generateMWF(getAnswer(o1Val), "12", "14")); t.addCourseAvaliability(generateMWF(getAnswer(p1Val), "14", "16")); t.addCourseAvaliability(generateMTT(getAnswer(q1Val), "18", "15", "20", "45")); t.addCourseAvaliability(generateMTW(getAnswer(r1Val), "18", "30", "20", "30")); t.addCourseAvaliability(generateTTT(getAnswer(s1Val), "10", "12")); t.addCourseAvaliability(generateTTT(getAnswer(t1Val), "12", "14")); t.addCourseAvaliability(generateTTT(getAnswer(u1Val), "14", "16")); t.addCourseAvaliability(generateTTT(getAnswer(v1Val), "18", "30", "20", "30")); t.addCourseAvaliability(generateTTT(getAnswer(w1Val), "06", "09")); t.addCourseAvaliability(generateTTT(getAnswer(x1Val), "09", "12")); t.addCourseAvaliability(generateWF(getAnswer(y1Val), "06", "09")); t.addCourseAvaliability(generateWF(getAnswer(z1Val), "07", "00", "08", "30")); t.addCourseAvaliability(generateTTT(getAnswer(aa1Val), "12", "00", "13", "30")); t.addCourseAvaliability(generateTTT(getAnswer(ab1Val), "07", "00", "08", "30")); System.out.println(t); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:eafit.cdei.asignacion.input.ReadTeacherPreferences.java
public List<Teacher> loadTeacherPreferences() throws Exception { try {/*from www. ja va2 s .c o m*/ FileInputStream fileInputStream = new FileInputStream("TeacherPreferences.xls"); HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream); HSSFSheet worksheet = workbook.getSheet("Preferences"); boolean keepDoing = true; for (int i = 1; i < worksheet.getLastRowNum() + 1; i++) { HSSFRow row1 = worksheet.getRow(i); HSSFCell cellA1 = row1.getCell((short) 0); String a1Val = cellA1.getNumericCellValue() + ""; HSSFCell cellB1 = row1.getCell((short) 1); String b1Val = cellB1.getStringCellValue(); HSSFCell cellC1 = row1.getCell((short) 2); String c1Val = cellC1.getStringCellValue(); String d1Val = ""; HSSFCell cellD1 = row1.getCell((short) 3); if (cellD1 != null) { d1Val = cellD1.getStringCellValue(); } HSSFCell cellE1 = row1.getCell((short) 4); double e1Val = cellE1.getNumericCellValue(); if (a1Val == null || a1Val.length() == 0 || a1Val.equals("0")) { keepDoing = false; } Teacher t = new Teacher(); t.setFullName(b1Val); t.setMaxCourses((int) e1Val); String[] preferedCourses = c1Val.split(","); ArrayList<LevelCourse> preferedCoursed = new ArrayList<LevelCourse>(); for (String preferedCoursed1 : preferedCourses) { LevelCourse lc = new LevelCourse(); lc.setLevelName(preferedCoursed1); preferedCoursed.add(lc); } String[] preferedTimes = d1Val.split(","); ArrayList<String> preferedTime = new ArrayList<>(); for (String pf : preferedTimes) { preferedTime.add(pf); } t.setListPreferedCourses(preferedCoursed); System.out.println(t); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:edu.fcps.hutchison.LabelBuilder.java
License:Open Source License
/** * Derive the schema from the contents of an Excel workbook *//*from w w w . j av a 2s . com*/ protected void generate() throws Exception { //start at the second row of the first sheet -the first row has the column names HSSFSheet sheet = _excelWorkbook.getSheetAt(0); HSSFSheet outSheet = newWorkbook.createSheet(); int rowct = 1; int newRows = 1; while (true) { HSSFRow row = sheet.getRow(rowct); if (row == null) { break; } HSSFCell cell = row.getCell(COPIES_COLUMN); if (cell == null) { break; } String copies = getCellValStr(cell); if (copies.equals("") || copies == null) { //last row is blank...return break; } int numCopies; try { numCopies = (int) cell.getNumericCellValue(); //gives 0 for empty cells } catch (java.lang.IllegalStateException e) { continue; } for (int j = 0; j < numCopies; j++) { HSSFRow outRow = outSheet.createRow(newRows); for (int i = 0; i < COLUMNS; i++) { System.out.println(row.getCell(i)); //TODO write to the new workbook outRow.createCell(i).setCellValue(getCellValStr(row.getCell(i))); } newRows++; } rowct++; } OutputStream os = new FileOutputStream("test.xls"); newWorkbook.write(os); os.close(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.XLSExport.java
License:Open Source License
/** * @param workSheet//from w w w .j ava2 s.c o m * writes headers for imagePath and geocoord (bg) data columns */ protected void writeExtraHeaders(final HSSFSheet workSheet, Vector<Integer> imgCols, int geoDataCol) { HSSFRow hssfRow = workSheet.getRow(0); if (geoDataCol != -1) { hssfRow.createCell(geoDataCol).setCellValue(new HSSFRichTextString(DataImport.GEO_DATA_HEADING)); } for (Integer c : imgCols) { hssfRow.createCell(c).setCellValue(new HSSFRichTextString(DataImport.IMAGE_PATH_HEADING)); } }
From source file:edu.tum.cs.conqat.quamoco.ExcelUtils.java
License:Apache License
/** * Check if column has correct headline. *//* www .j av a2 s .com*/ public static void checkName(HSSFSheet sheet, int colNo, String title) throws ConQATException { if (!title.equals(getCellText(sheet.getRow(0), colNo))) { throw new ConQATException("Invalid headline"); } }