Recently I needed to parse simple Excel sheet to XML format.
Excel does support this operation, but as everything from MS, the process is very intuitive.
Firs you have to create XML Schema with the desired attributes. Then you must map these attributes to the Excel ones. Sounds simple but after 30 minutes clicking in the menus I decided to write a parser in Java myself .
Firs you must download JExcelApi from here.
The way this API is used is fairly simple:
[java]
File inputWorkbook = new File("Name_of_excel_file");
Workbook w;
try {
w = Workbook.getWorkbook(inputWorkbook);
Sheet sheet = w.getSheet(0);
for (int j = 0; j < sheet.getColumns(); j++) {
for (int i = 0; i < sheet.getRows(); i++) {
Cell cell = sheet.getCell(j, i);
System.out.print(cell.getContents()+ " ");
//do xml parse job
}
System.out.println();
}
} catch (BiffException e) {
e.printStackTrace();
}
[/java]
So next time you need something simple like that, first consider writing it yourself…