I made an excel file using jExcel API, but when I tried to open that file I got error filename.xls:file format is not valid and I can not open this file, here is my Java code
File file = new File("C:\\Users\\Giga\\Desktop\\yvela.xls");
WritableWorkbook wb = Workbook.createWorkbook(file);
WritableSheet wsheet = wb.createSheet("First Sheet", 0);
int row = 0;
for (Student student : students) {
wsheet.addCell(new Label(0, row, student.getName()));
wsheet.addCell(new Label(1, row, student.getSurname()));
row++;
}
wb.close();
You need to call wb.write()
before wb.close()
.
The write
method finalizes some things and actually writes the data to the file.