Open zo-zero-one opened 3 years ago
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:
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: @.***>
Did you look at the Excel importing feature? I'm not sure if it does .xls since that's an older file format.