Set Text field from ObservableList [JavaFX]

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Set Text field from ObservableList [JavaFX]

luca120
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&lt;MainTableGlobalWip.getItems().size();row++){
            XSSFRow xssfRow= masterDataSheet.createRow(row+1);
            for (int col=0; col&lt;MainTableGlobalWip.getColumns().size();
col++){
            Object celValue =
MainTableGlobalWip.getColumns().get(col).getCellObservableValue(row).getValue();
           
            try {
            if (celValue != null &amp;&amp;
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(&quot;C:\\Users\\lroscio\\Desktop\\Wip_&quot;+timeStamp+&quot;.xlsx&quot;));
         }&lt;/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]