Hello to all,
i'm tryng to generate one excel file from ObservableList by adding one column like Text because without this paramiter in this specific column I can loose some informations. field MainTableGlobalWip is --> @FXML private TableView<ListTableGlobalWip> MainTableGlobalWip; field ListTableGlobalWip is ---> @FXML private ObservableList<ListTableGlobalWip> data ; below is possible to see the code which I'm using to generate the excel file by using Apache POI 4.1 XSSFWorkbook workbook = new XSSFWorkbook(); XSSFCellStyle textFormatStyle = workbook.createCellStyle(); XSSFSheet masterDataSheet= workbook.createSheet("Master_Data"); XSSFRow firstRow= masterDataSheet.createRow(0); XSSFRow row = null; //XSSFCell cell =row.createCell(0); public void ExportXlsx(ActionEvent actionEvent) throws IOException { //prelevo le intestazioni delle colonne for (int i=0; i<MainTableGlobalWip.getColumns().size();i++) { firstRow.createCell(i).setCellValue(MainTableGlobalWip.getColumns().get(i).getText()); } //inizio a prelevare i vari record dalla tabella e li trasferisco all'interno del file EXEL for(int row=0; row<MainTableGlobalWip.getItems().size();row++){ XSSFRow xssfRow= masterDataSheet.createRow(row+1); for (int col=0; col<MainTableGlobalWip.getColumns().size(); col++){ Object celValue = MainTableGlobalWip.getColumns().get(col).getCellObservableValue(row).getValue(); try { if (celValue != null && Double.parseDouble(celValue.toString()) != 0.0) { xssfRow.createCell(col).setCellValue(Double.parseDouble(celValue.toString())); } }catch(NumberFormatException e){ xssfRow.createCell(col).setCellValue(celValue.toString()); } } } workbook.write(new FileOutputStream("C:\\Users\\lroscio\\Desktop\\Wip_"+timeStamp+".xlsx")); }</h2> someone could help me to put the column 16 like text for don't loos the informations? -- Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
Free forum by Nabble | Edit this page |