I tried write into xls in following

ServletOutputStream outStream = response.getOutputStream();
SXSSFWorkbook wb = new SXSSFWorkbook(1000);
int rowcount =0;
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment; filename=\""+ stFileName + ".xls" + "\"");
Sheet sh = wb.createSheet();
Row rw = sh.createRow(0);
for(int headCnt=0;headCnt<headers.size();headCnt++){
Cell cell = rw.createCell(headCnt);
cell.setCellValue(headers.get(headCnt));
}
while(rs.next())
{
int columnCount = rs.getMetaData().getColumnCount();
rowcount++;
rw = sh.createRow(rowcount);
for (int column = 0; column <columnCount; column++) {
Cell cell = rw.createCell(column);
cell.setCellValue(rs.getString(column+1));
}

}

wb.write(outStream);

Microsoft excel warn getting as " The file you're trying to open 'ABC DATA.xls', is in a different format than specified by the file extension. verify that the file is not corrupted and is from a trusted source before opening file. ".

I tried with the diff extensions .xls, .xlsx and .csv

Could you let me know your inputs here

Thanks,
Rajesh