private static void writeExcel() throws IOException, RowsExceededException,
WriteException {
File xlsFile = new File("jxl.xls");
WritableWorkbook workbook = Workbook.createWorkbook(xlsFile);
WritableSheet sheet = workbook.createSheet("sheet1", 0);
for (int row = 0; row < 10; row++) {
for (int col = 0; col < 10; col++) {
sheet.addCell(new Label(col, row, "data" + row + col));
}
}
workbook.write();
workbook.close();
}
private static void readExcel() throws BiffException, IOException {
File xlsFile = new File("students.xls");
Workbook workbook = Workbook.getWorkbook(xlsFile);
Sheet[] sheets = workbook.getSheets();
if (sheets != null) {
for (Sheet sheet : sheets) {
int rows = sheet.getRows();
int cols = sheet.getColumns();
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
Cell cell = sheet.getCell(col, row);
System.out.print(cell.getContents() + " ");
}
System.out.println();
}
}
}
workbook.close();
}