There are too many examples how to create EXCEL file, like this: create Excel with xPages
But I really need Excel xlsx format not xls. Just defining xlsx file extension and change content type doesn't help:
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
Vlad, Setting the content type to xls or xlsx has the same effect: it tells the browser to hand over to Excel. It still would send HTML that excel renders. It is up to the user to save as xlsx.
If you really need a ready made xlsx you need to create an XAgent that renders the binary xlsx format. The easiest way is Apache POI library, which is available for XPages through OpenNTF.
Check the samples there. They should do what you need.