BigZoo
BigZoo

Reputation: 41

Writing on Excel

When I write in an Excel file certain information, it's recorded only the cells in the first row, and the rest are empty:

for(int i = 0; i < 10; i++) {
            Label data1 = new Label(1, i, "1");
            wsheet.addCell(data1);
            Label data2 = new Label(2, i, "2");
            wsheet.addCell(data2);
            Label data3 = new Label(3, i, "3");
            wsheet.addCell(data3);
            wworkbook.write();
}
wworkbook.close();  

How to change the code to post conducted in all ten rows?

Upvotes: 0

Views: 41

Answers (1)

MacroMarc
MacroMarc

Reputation: 3324

You're currently writing inside the loop. Try writing outside of the loop:

 for(int i = 0; i < 10; i++) {
        Label data1 = new Label(1, i, "1");
        wsheet.addCell(data1);
        Label data2 = new Label(2, i, "2");
        wsheet.addCell(data2);
        Label data3 = new Label(3, i, "3");
        wsheet.addCell(data3);
   }
   wworkbook.write();   
   wworkbook.close();  

Upvotes: 1

Related Questions