JAVA - saving excel (office 2010) without format warning -


i have write data in excel file. when i'm opening excel file data, teher appears warning:

`the file trying open, 'name.xls', in different format specified file extension. verify file not corrupted , thrusted source before opening file. want open file now?` 

i'm using microsoft excel 2010. , when i'm creating httpservletresponse response i'm adding such information header , content type:

response.setcontenttype("application/vnd.ms-excel"); response.setheader("content-disposition", info file name + ".xls\""); 

i have tried set header like: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet , file format .xlsx, doesn't because warning still appears.

when i'm trying use .csv or .xml format, don't have problem, because no warning appears. there possibility programmatically rid of warning?

the file trying open, 'name.xls', in different format specified file extension...

that standard excel warning when loading xlsx file xls extension. there no way avoid programmatically. have fix underlying mismatch issue.

to debug:

  1. save local copy of file, change extension xlsx , see if loads in excel without warning.

  2. if adjust contenttype headers suit.

  3. if doesn't file may in other format. find out format , again adjust headers/filename suit.

see answer here extension hardening.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -