tablesaw
tablesaw copied to clipboard
Could you support .xls file?
Did you look at the Excel importing feature? I'm not sure if it does .xls since that's an older file format.
Late to the party but may be of use to others...
To support "xls", the HSSFWorkbook, HSSFSheet, HSSFRow and HSSFCell classes should be used. Code in:
https://github.com/jtablesaw/tablesaw/blob/1841f041e9d517a332542e1042c2ea261ae83f88/excel/src/main/java/tech/tablesaw/io/xlsx/XlsxReader.java#L119
shows the use of XSSFWorkbook. That and the XSSFSheet, XSSFRow and XSSFCell classes that support xlsx. See https://www.baeldung.com/java-microsoft-excel.
So, not supported. Also may not be so trivial to support it.
HTHs
Found this article that shows that maybe with one simple change it can be supported:
private Workbook getWorkbook(FileInputStream inputStream, String excelFilePath)
throws IOException {
Workbook workbook = null;
if (excelFilePath.endsWith("xlsx")) {
workbook = new XSSFWorkbook(inputStream);
} else if (excelFilePath.endsWith("xls")) {
workbook = new HSSFWorkbook(inputStream);
} else {
throw new IllegalArgumentException("The specified file is not Excel file");
}
return workbook;
}
One small issue though, POI does not support the raw XML format prior 2003.
Thanks!
---Original--- From: @.> Date: Fri, Aug 12, 2022 01:23 AM To: @.>; Cc: @.@.>; Subject: Re: [jtablesaw/tablesaw] Could you support .xls file? (#956)
Found this article that shows that maybe with one simple change it can be supported: private Workbook getWorkbook(FileInputStream inputStream, String excelFilePath) throws IOException { Workbook workbook = null; if (excelFilePath.endsWith("xlsx")) { workbook = new XSSFWorkbook(inputStream); } else if (excelFilePath.endsWith("xls")) { workbook = new HSSFWorkbook(inputStream); } else { throw new IllegalArgumentException("The specified file is not Excel file"); } return workbook; }
One small issue though, POI does not support the raw XML format prior 2003.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>