I'm trying to export a spreadsheet with Java, specifically a .xlsx
file, but I'm not getting it.
I'm doing it this way and it's working, but it only works by putting the extension .xls
:
HSSFWorkbook workbook = new HSSFWorkbook();
String PathTillProject = System.getProperty("user.dir");
FileOutputStream fileOut = null;
fileOut = new FileOutputStream(PathTillProject + "/src/Export.xls");
workbook.write(fileOut);
If I put in fileOut
the extension .xlsx
, at the time of opening the file, it says that the extension of the file is not valid.
I'm importing the following file:
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
What should I do to be able to export with another extension?