tags:

views:

71

answers:

1

I manage to create Excel 97-2003 file with Java, but when I try to open it with Windows Explorer, I get the error message file format is not valid. The filename is file.xls so it should be right? What goes wrong then?

+1  A: 

Question is not clear. How was you creating excel file with Java? The problem is because tool you used for file creation created it incorrectly, in incorrect format.

Consider using Apache POI library: http://poi.apache.org/spreadsheet/index.html I was using it for a while and it works correctly. I didn't have problems with it.

Andriy Sholokh
public static void write () throws IOException, WriteException { WorkbookSettings settings = new WorkbookSettings(); File seurantaraportti = new File(ta.xls"); WritableWorkbook seurw = Workbook.createWorkbook(ta,settings); seurw.createSheet("ta", 0); WritableSheet ws = seurw.getSheet(0); addNumber(ws,0,0,100.0); seurw.close();}
jaana
private static void addNumber(WritableSheet sheet, int column, int row, Double d) throws WriteException, RowsExceededException { Number number=new Number(column, row,d); sheet.addCell(number); }
jaana