List of usage examples for org.apache.poi.xssf.usermodel XSSFSheet createRow
@Override public XSSFRow createRow(int rownum)
From source file:hangargame.xml.AfficherListGamerAdminController.java
@FXML void ExtraireExcel(ActionEvent event) throws FileNotFoundException, IOException { List<Gamer> l = new ArrayList(); l = s.AfficherListeGamer();// w w w .j av a 2s . c om XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet spreadsheet = workbook.createSheet("Hangar Game"); XSSFRow row = spreadsheet.createRow(1); XSSFCell cell; cell = row.createCell(1); cell.setCellValue("Login"); cell = row.createCell(2); cell.setCellValue("Nom"); cell = row.createCell(3); cell.setCellValue("Prenom"); cell = row.createCell(4); cell.setCellValue("E-mail"); cell = row.createCell(5); cell.setCellValue("Adresse"); cell = row.createCell(6); cell.setCellValue("Tlphone"); cell = row.createCell(7); cell.setCellValue("Data d'inscription"); cell = row.createCell(8); cell.setCellValue("Etat"); for (int i = 1; i < l.size() - 1; i++) { row = spreadsheet.createRow(i); cell = row.createCell(1); cell.setCellValue(l.get(i).getLogin()); cell = row.createCell(2); cell.setCellValue(l.get(i).getNom()); cell = row.createCell(3); cell.setCellValue(l.get(i).getPrenom()); cell = row.createCell(4); cell.setCellValue(l.get(i).getEmail()); cell = row.createCell(5); cell.setCellValue(l.get(i).getAdresse()); cell = row.createCell(6); cell.setCellValue(l.get(i).getTel()); cell = row.createCell(7); cell.setCellValue(l.get(i).getDateInscription()); cell = row.createCell(8); cell.setCellValue(l.get(i).getEtat()); } FileOutputStream out = new FileOutputStream(new File("exceldatabase.xlsx")); workbook.write(out); out.close(); tray.notification.TrayNotification tr = new TrayNotification(); tr.setTitle("Extraction faite avec succes"); tr.setMessage("Tlechargement sous Document/netbeans/hangargame "); tr.setNotificationType(NotificationType.SUCCESS); tr.setAnimationType(AnimationType.SLIDE); tr.showAndDismiss(Duration.seconds(5)); }
From source file:hedicim.HEDICIM.java
static void exportResults(Set<Patient> patients) { SummaryReportWriter srw = new SummaryReportWriter(Const.OUTPUT_FOLDER + execution_label + " Summary.txt"); srw.write("## Summary report for HEDICIM labeled: \"" + execution_label + "\" ##"); srw.write("# LAB_TIME_WINDOW: " + Const.LAB_TIME_WINDOW); srw.write("# EARLY_DEATH_TIME_WINDOW: " + Const.EARLY_DEATH_TIME_WINDOW); srw.write("# IGNORE_DIC_IF_NEAR_DEATH: " + Const.IGNORE_DIC_IF_NEAR_DEATH); srw.write("# IGNORE_MEDICATION_IF_FAR_FROM_DIC: " + Const.IGNORE_MEDICATION_IF_FAR_FROM_DIC); srw.write("# debug_patient_number_limiter: " + Const.debug_patient_number_limiter); srw.write("# origin_ids_chunk_size: " + Const.processing_chunk_size); if (Const.do_MIMICII) { srw.write("# ICD9_queries.length: " + Const.ICD9_queries.length); for (int i = 0; i < Const.ICD9_queries.length; i++) srw.write("# > ICD9_queries[" + i + "]: " + Const.ICD9_queries[i]); }/*ww w . ja va2 s. c om*/ if (Const.do_BTRIS) srw.write("# BTRIS table queried: " + Const.BTRIS_TABLE); srw.write("Total patients processed: " + count_of_all_patients_processed); srw.write("Total non-neonates processed: " + count_of_non_neonates_processed); srw.write("Total eligible patients found: " + eligible_count); int eligible_dic_count = 0; for (Patient patient : patients) if (patient.eligible && patient.has_dic) eligible_dic_count++; srw.write("Total eligible patients with DIC found: " + eligible_dic_count); /* srw.write("LABEVENTS exceptions: " + msc.LABEVENTS_exceptions); srw.write("ADMISSIONS exceptions: " + msc.ADMISSIONS_exceptions); srw.write("ICUSTAY_DETAIL exceptions: " + msc.ICUSTAY_DETAIL_exceptions); srw.write("D_PATIENTS exceptions: " + msc.D_PATIENTS_exceptions); srw.write("POE_ORDER exceptions: " + msc.POE_ORDER_exceptions); srw.write("CHARTEVENTS exceptions: " + msc.CHARTEVENTS_exceptions); */ srw.close(); EnumMap<DICSS, EnumMap<DICSS, Long[]>> scorers_comparison_table_time = compareDICSSOverlappingTime( patients); EnumMap<DICSS, EnumMap<DICSS, Long[]>> scorers_comparison_table_cases = compareDICSSOverlappingCases( patients); EnumMap<DICSS, DICScore> score_structures = buildScoreStructures(patients); try (FileOutputStream file = new FileOutputStream( new File(Const.OUTPUT_FOLDER + execution_label + " DICSS comparison.xlsx"))) { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet("DIC SS Overlapping Periods of Time"); int r = 0; Row row = sheet.createRow(r++); int c = 0; row.createCell(c++).setCellValue("Reference\\Comparison"); for (DICSS dicss_reference : DICSS.values()) row.createCell(c++).setCellValue(dicss_reference.name()); row.createCell(c++).setCellValue("Total reference time (weeks)"); for (DICSS dicss_reference : DICSS.values()) { row = sheet.createRow(r++); c = 0; row.createCell(c++).setCellValue(dicss_reference.name()); for (DICSS dicss_comparison : DICSS.values()) row.createCell(c++) .setCellValue(String.format("%.1f", 100d * ((double) (scorers_comparison_table_time.get(dicss_reference) .get(dicss_comparison)[0])) / ((double) (scorers_comparison_table_time.get(dicss_reference) .get(dicss_comparison)[1]))) + "%"); row.createCell(c++).setCellValue(String.format("%.1f", 100d * ((double) (scorers_comparison_table_time.get(dicss_reference).get(dicss_reference)[1])) / (1000d * 60d * 60d * 24d * 7d))); } sheet = workbook.createSheet("DIC SS Overlapping Cases"); r = 0; row = sheet.createRow(r++); c = 0; row.createCell(c++).setCellValue("Reference\\Comparison"); for (DICSS dicss_reference : DICSS.values()) row.createCell(c++).setCellValue(dicss_reference.name()); for (DICSS dicss_reference : DICSS.values()) { row = sheet.createRow(r++); c = 0; row.createCell(c++).setCellValue(dicss_reference.name()); for (DICSS dicss_comparison : DICSS.values()) row.createCell(c++) .setCellValue(String.format("%.1f", 100d * ((double) (scorers_comparison_table_cases.get(dicss_reference) .get(dicss_comparison)[0])) / ((double) (scorers_comparison_table_cases.get(dicss_reference) .get(dicss_comparison)[1]))) + "%"); } for (DICSS dicss : DICSS.values()) { sheet = workbook.createSheet(dicss.name() + " score structure"); r = 0; row = sheet.createRow(r++); c = 0; DICScore dic_score = score_structures.get(dicss); if (dic_score.itemids.isEmpty()) { row.createCell(c++).setCellValue("Empty."); continue; } row.createCell(c++).setCellValue("ITEMID"); row.createCell(c++).setCellValue("Contribution to score (%)"); for (ITEMID itemid : dic_score.itemids.keySet()) { row = sheet.createRow(r++); c = 0; row.createCell(c++).setCellValue(itemid.name()); row.createCell(c++).setCellValue(100d * dic_score.itemids.get(itemid)); } row = sheet.createRow(r++); c = 0; row.createCell(c++).setCellValue("Average score"); row.createCell(c++).setCellValue(dic_score.score); } workbook.write(file); file.close(); } catch (Exception ex) { System.out.print("Unable to open " + Const.OUTPUT_FOLDER + execution_label + " DICSS comparison.xlsx" + " for writing:\n" + ex.getMessage()); } }
From source file:ik1004labb5.DAOHundExcel.java
@Override public void add(DTOHund dtoHund) { XSSFWorkbook workbook = getExcelWorkbook(); XSSFSheet worksheet = workbook.getSheetAt(0); //G ner i hierarkun frn workbook, till sheet row osv. XSSFRow row = worksheet.createRow(worksheet.getLastRowNum() + 1); XSSFCell id = row.createCell(0); //skapa celler fr varje "instans", namn, ras osv. XSSFCell namn = row.createCell(1);/*from ww w.jav a 2s . c o m*/ XSSFCell ras = row.createCell(2); XSSFCell bildURL = row.createCell(3); //XSSFCell iHundgrd = row.createCell(4); id.setCellValue(Integer.toString(dtoHund.getId())); namn.setCellValue(dtoHund.getNamn()); ras.setCellValue(dtoHund.getRas()); bildURL.setCellValue(dtoHund.getBildURL()); //iHundgrd.setCellValue(dtoHund.isiHundgrd().get()); //worksheet.createRow(worksheet.getLastRowNum() + 1); FRBANNELSENS RAD! Visa Elin. saveToExcel(workbook); }
From source file:Import.Utils.XSSFConvert.java
/** * @param destination the sheet to create from the copy. * @param the sheet to copy.//from w ww . j av a2 s . com * @param copyStyle true copy the style. */ public static void copySheets(HSSFSheet source, XSSFSheet destination, boolean copyStyle) { int maxColumnNum = 0; Map<Integer, HSSFCellStyle> styleMap = (copyStyle) ? new HashMap<Integer, HSSFCellStyle>() : null; for (int i = source.getFirstRowNum(); i <= source.getLastRowNum(); i++) { HSSFRow srcRow = source.getRow(i); XSSFRow destRow = destination.createRow(i); if (srcRow != null) { copyRow(source, destination, srcRow, destRow, styleMap); if (srcRow.getLastCellNum() > maxColumnNum) { maxColumnNum = srcRow.getLastCellNum(); } } } for (int i = 0; i <= maxColumnNum; i++) { destination.setColumnWidth(i, source.getColumnWidth(i)); } }
From source file:in.expertsoftware.colorcheck.FormatvarificationErrorList.java
public void dumpFormatErrorToExcelFile(ArrayList<ErrorModel> get_errormodelList) throws FileNotFoundException, IOException { /***//from ww w . j a v a2 s. com Dump the error list into Excel file.***/ XSSFWorkbook ErrorWorkbook = new XSSFWorkbook(); XSSFSheet ErrorSheet; for (int i = 0; i < get_errormodelList.size(); i++) { int index = ErrorWorkbook.getSheetIndex(get_errormodelList.get(i).sheet_name); if (index == -1) { ErrorSheet = ErrorWorkbook.createSheet(get_errormodelList.get(i).sheet_name); XSSFRow totalError = ErrorSheet.createRow(0); XSSFRow totalWarning = ErrorSheet.createRow(1); CreaateHeaderOfErrorList(ErrorWorkbook, totalError.createCell(0), "Total Errors"); CreaateHeaderOfErrorList(ErrorWorkbook, totalWarning.createCell(0), "Total Warnings"); if ((get_errormodelList.get(i).error_level).equals("Warning")) { totalWarning.createCell(1).setCellValue(1); } else totalWarning.createCell(1).setCellValue(0); if ((get_errormodelList.get(i).error_level).equals("Error")) { totalError.createCell(1).setCellValue(1); } else totalError.createCell(1).setCellValue(0); ErrorSheet.createRow(2); XSSFRow headerrow = ErrorSheet.createRow(3); //create header of every sheet Cell Header_referenceCell = headerrow.createCell(0); CreaateHeaderOfErrorList(ErrorWorkbook, Header_referenceCell, "Cell Ref"); Cell Header_sheetname = headerrow.createCell(1); CreaateHeaderOfErrorList(ErrorWorkbook, Header_sheetname, "Sheet Name"); Cell Header_ErrorDesc = headerrow.createCell(2); CreaateHeaderOfErrorList(ErrorWorkbook, Header_ErrorDesc, "Error Description"); Cell Header_ErrorLevel = headerrow.createCell(3); CreaateHeaderOfErrorList(ErrorWorkbook, Header_ErrorLevel, "Error Level"); XSSFRow row = ErrorSheet.createRow(4); row = ErrorSheet.createRow(5); CreaateStyleOfErrorList(ErrorWorkbook, row, get_errormodelList.get(i).cell_ref, get_errormodelList.get(i).sheet_name, get_errormodelList.get(i).error_desc, get_errormodelList.get(i).error_level); ErrorSheet.autoSizeColumn(0); ErrorSheet.autoSizeColumn(1); ErrorSheet.autoSizeColumn(2); ErrorSheet.autoSizeColumn(3); } else { printinfo(ErrorWorkbook, get_errormodelList.get(i).cell_ref, get_errormodelList.get(i).sheet_name, get_errormodelList.get(i).error_desc, get_errormodelList.get(i).error_level); } } setColorInfoMetaData(ErrorWorkbook); try (FileOutputStream ErrorOutputStream = new FileOutputStream( "C:/Users/Dharam/Desktop/DIMT_NEW_CODE/ErrorSheet.xlsx")) { ErrorWorkbook.write(ErrorOutputStream); } }
From source file:in.expertsoftware.colorcheck.FormatvarificationErrorList.java
private static void printinfo(XSSFWorkbook ErrorWorkbook, String cell_ref, String sheet_name, String error_desc, String error_level) {// w ww . ja v a 2 s . c om XSSFSheet ErrorSheet = ErrorWorkbook.getSheet(sheet_name); if (error_level.equals("Error")) { ErrorSheet.getRow(0).getCell(1).setCellValue(1 + ErrorSheet.getRow(0).getCell(1).getNumericCellValue()); } else if (error_level.equals("Warning")) { ErrorSheet.getRow(1).getCell(1).setCellValue(1 + ErrorSheet.getRow(1).getCell(1).getStringCellValue()); } XSSFRow row = ErrorSheet.createRow(ErrorSheet.getPhysicalNumberOfRows()); CreaateStyleOfErrorList(ErrorWorkbook, row, cell_ref, sheet_name, error_desc, error_level); }
From source file:in.expertsoftware.colorcheck.FormatvarificationErrorList.java
private static void setColorInfoMetaData(XSSFWorkbook ErrorWorkbook) { //Set Colour used information on first sheet. XSSFSheet setInfoSheet = ErrorWorkbook.getSheetAt(0); XSSFRow colourInfoRow;//from w w w. j a v a 2 s .c o m XSSFRow errorColourRow; XSSFRow warningColourRow; if (setInfoSheet.getPhysicalNumberOfRows() > 5) { colourInfoRow = setInfoSheet.getRow(5); } else { colourInfoRow = setInfoSheet.createRow(5); } Cell colorInfoCell = colourInfoRow.createCell(6); Cell RGBCell = colourInfoRow.createCell(7); CreaateHeaderOfErrorList(ErrorWorkbook, colorInfoCell, "Used Color"); CreaateHeaderOfErrorList(ErrorWorkbook, RGBCell, "RGB Value"); setInfoSheet.autoSizeColumn(6); setInfoSheet.autoSizeColumn(7); if (setInfoSheet.getPhysicalNumberOfRows() > 6) { errorColourRow = setInfoSheet.getRow(6); } else { errorColourRow = setInfoSheet.createRow(6); } if (setInfoSheet.getPhysicalNumberOfRows() > 7) { warningColourRow = setInfoSheet.getRow(7); } else { warningColourRow = setInfoSheet.createRow(7); } //error color style XSSFCellStyle errorStyle = ErrorWorkbook.createCellStyle(); errorStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); errorStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(225, 171, 171))); errorColourRow.createCell(6).setCellStyle(errorStyle); errorColourRow.getCell(6).setCellValue("Error"); errorColourRow.createCell(7).setCellValue("225, 171, 171"); //warning color style XSSFCellStyle warningStyle = ErrorWorkbook.createCellStyle(); warningStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); warningStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(155, 194, 230))); warningColourRow.createCell(6).setCellStyle(warningStyle); warningColourRow.getCell(6).setCellValue("Warning"); warningColourRow.createCell(7).setCellValue("155, 194, 230"); }
From source file:Interface.interemploi.java
private void writetoxel() { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet ws = wb.createSheet(); TreeMap<String, Object[]> data = new TreeMap<>(); data.put("0", new Object[] { mod.getColumnName(0), mod.getColumnName(1), mod.getColumnName(2), mod.getColumnName(3), mod.getColumnName(4), mod.getColumnName(5), mod.getColumnName(6), mod.getColumnName(7), mod.getColumnName(8), mod.getColumnName(9), mod.getColumnName(10), mod.getColumnName(11), mod.getColumnName(12), mod.getColumnName(13), mod.getColumnName(14), mod.getColumnName(15), mod.getColumnName(16), mod.getColumnName(17), mod.getColumnName(18), mod.getColumnName(19) }); int nb = mod.getRowCount(); int s = 0;/*from www. ja v a 2 s .c o m*/ for (int i = 1; i <= nb; i++) { data.put(Integer.toString(i), new Object[] { getvlue(s, 0), getvlue(s, 1), getvlue(s, 2), getvlue(s, 3), getvlue(s, 4), getvlue(s, 5), getvlue(s, 6), getvlue(s, 7), getvlue(s, 8), getvlue(s, 9), getvlue(s, 10), getvlue(s, 11), getvlue(s, 12), getvlue(s, 13), getvlue(s, 14), getvlue(s, 15), getvlue(s, 16), getvlue(s, 17), getvlue(s, 18), getvlue(s, 19) }); s++; } Set<String> ids = data.keySet(); XSSFRow row; int rowID = 0; for (String key : ids) { row = ws.createRow(rowID++); Object[] values = data.get(key); int cellID = 0; for (Object o : values) { Cell cell = row.createCell(cellID++); cell.setCellValue(o.toString()); } } try { FileOutputStream fs; fs = new FileOutputStream(new File("bdd_Fonctionaire.xlsx")); wb.write(fs); fs.close(); JOptionPane.showConfirmDialog(null, "Votre Base De Donnee Est Bien Expoter", "Valider", JOptionPane.CLOSED_OPTION); Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("bdd_Fonctionaire.xlsx")); } else { System.out.println("Open is not supported"); } } catch (FileNotFoundException ex) { System.out.println("eruer fichier"); } catch (IOException ex) { System.out.println("eruer fichier"); } }
From source file:Interface.interProf.java
private void writetoxel() { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet ws = wb.createSheet(); TreeMap<String, Object[]> data = new TreeMap<>(); data.put("0", new Object[] { mod.getColumnName(0), mod.getColumnName(1), mod.getColumnName(2), mod.getColumnName(3), mod.getColumnName(4), mod.getColumnName(5), mod.getColumnName(6), mod.getColumnName(7), mod.getColumnName(8), mod.getColumnName(9), mod.getColumnName(10), mod.getColumnName(11), mod.getColumnName(12), mod.getColumnName(13), mod.getColumnName(14), mod.getColumnName(15), mod.getColumnName(16), mod.getColumnName(17), mod.getColumnName(18), mod.getColumnName(19), mod.getColumnName(20) }); int nb = mod.getRowCount(); int s = 0;//from www .j av a 2s .co m for (int i = 1; i <= nb; i++) { data.put(Integer.toString(i), new Object[] { getvlue(s, 0), getvlue(s, 1), getvlue(s, 2), getvlue(s, 3), getvlue(s, 4), getvlue(s, 5), getvlue(s, 6), getvlue(s, 7), getvlue(s, 8), getvlue(s, 9), getvlue(s, 10), getvlue(s, 11), getvlue(s, 12), getvlue(s, 13), getvlue(s, 14), getvlue(s, 15), getvlue(s, 16), getvlue(s, 17), getvlue(s, 18), getvlue(s, 19), getvlue(s, 20) }); s++; } Set<String> ids = data.keySet(); XSSFRow row; int rowID = 0; for (String key : ids) { row = ws.createRow(rowID++); Object[] values = data.get(key); int cellID = 0; for (Object o : values) { Cell cell = row.createCell(cellID++); cell.setCellValue(o.toString()); } } try { FileOutputStream fs; fs = new FileOutputStream(new File("bdd_prof.xlsx")); wb.write(fs); fs.close(); JOptionPane.showConfirmDialog(null, "Votre Base De Donnee Est Bien Expoter", "Valider", JOptionPane.CLOSED_OPTION); Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("bdd_prof.xlsx")); } else { System.out.println("Open is not supported"); } } catch (FileNotFoundException ex) { System.out.println("eruer fichier"); } catch (IOException ex) { System.out.println("eruer fichier"); } }
From source file:io.excel.AnnotationExcelIO.java
public void save() { resultEditor.annotations.Depot depot = new resultEditor.annotations.Depot(); try {/*w w w . j a v a 2 s . c o m*/ int rowcount = 0; File project = env.Parameters.WorkSpace.CurrentProject; if (project == null) { return; } XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet1 = wb.createSheet("Annotation_by_att"); // XSSFRow row0 = sheet1.createRow(0); row0.createCell((short) 0).setCellValue("Project Name"); row0.createCell((short) 1).setCellValue("Annotation ID"); row0.createCell((short) 2).setCellValue("Annotation Text"); row0.createCell((short) 3).setCellValue("Annotation Class"); row0.createCell((short) 4).setCellValue("Full Span"); row0.createCell((short) 5).setCellValue("Span Start"); row0.createCell((short) 6).setCellValue("Span End"); row0.createCell((short) 7).setCellValue("Created Date"); row0.createCell((short) 8).setCellValue("Annotator Name"); row0.createCell((short) 9).setCellValue("Annotator ID"); row0.createCell((short) 10).setCellValue("Attributes"); row0.createCell((short) 11).setCellValue("Relaionships"); row0.createCell((short) 11).setCellValue("Contents"); for (Article article : depot.getDepot()) { if (article == null) { continue; } if (article.annotations == null) { continue; } // go through all annotation for each article for (Annotation annotation : article.annotations) { if (annotation == null) { continue; } rowcount++; XSSFRow row1 = sheet1.createRow(rowcount); // project name row1.createCell((short) 0).setCellValue(project.getName()); // annotation id row1.createCell((short) 1).setCellValue(annotation.mentionid); // current annotator name row1.createCell((short) 2).setCellValue(annotation.annotationText); // class row1.createCell((short) 3).setCellValue(annotation.annotationclass); // span info row1.createCell((short) 4).setCellValue(annotation.getSpansInText()); row1.createCell((short) 5).setCellValue(annotation.spanset.getMinimumStart()); row1.createCell((short) 6).setCellValue(annotation.spanset.getMaximumEnd()); // create time row1.createCell((short) 7).setCellValue(annotation.creationDate); // annotator row1.createCell((short) 8).setCellValue(annotation.getAnnotator()); row1.createCell((short) 9).setCellValue(annotation.annotatorid); row1.createCell((short) 10).setCellValue(annotation.getAttributeString()); row1.createCell((short) 11).setCellValue(annotation.getComplexRelationshipString()); String textcontent = PreLoadDocumentContents.getSurroundText(annotation, article); row1.createCell((short) 12).setCellValue(textcontent); } } // BUILD THE FILE NAME String filename = project.getAbsolutePath() + File.separatorChar + "AnnotationsInExcel.xlsx"; System.out.println("Annotation results are saved on MS EXCEL Format:" + filename); // OUTPUT THE FILE TO DISK FileOutputStream fileOut = new FileOutputStream(filename); wb.write(fileOut); fileOut.close(); // CLOSE } catch (Exception ex) { ex.printStackTrace(); } }