Domanda

i've created an application for converting json to excel , The code works fine but nothing is writing into excel sheet generated. can anyone please tell me the reason for this.

jxl library for excel convertion

My code is given below

 public static void majin(String[] args) throws Exception
        {   

            WritableWorkbook wworkbook;
            wworkbook = Workbook.createWorkbook(new File("C:/SWD.csv"));
            WritableSheet wsheet = wworkbook.createSheet("SWD", 0);

            WritableFont cellFont = new WritableFont(WritableFont.TIMES, 12);
            cellFont.setColour(Colour.BLACK);
            WritableCellFormat cellFormat = new WritableCellFormat(cellFont);

            cellFormat.setBackground(Colour.WHITE); 
            cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
            Label label = new Label(0, 0,"mydata",cellFormat);
            wsheet.setColumnView(0, 18);
            wsheet.addCell(label); 

        }
È stato utile?

Soluzione

I guess you have missed following line to write data to excel file:

wsheet.write();

And you can close the file after writing data into file like:

wsheet.close();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top