0

I have an application deployed on WebLogic12c-- app was recently migrated to 12c. When I try to export a report to an excel, it shows me a warning message(the file you are trying to open is in a different format than specified by the file extension....) and then says the file is corrupted. But the same file if I try to save and open, it still shows the warning message but it opens in excel with data. Here is my export excel action class...

String header = "attachment; filename=" + filename + "-"
              + new Date().getTime() + ".xls;";
response.setContentType("application/vnd.ms-excel;name=\"bestellnummer\"");
response.setHeader("Content-Disposition",header);

I am not sure if the issue is in WebLogic or code.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Excel files are binary files, when they transfer over the net it could be corrupted. You should send SHA1 or MD5 checksum along with the file to check if the file is corrupted. – Roman C Sep 07 '16 at 08:29
  • am totally new to this, can anyone please help me understand. We also have migrated out certs to SHA2 – srinivas vallap Sep 07 '16 at 14:12
  • you should check the format that you save first then open, if excel file is saved with 2007 or higher then it has different format to prior versions. For compatibility reasons it can be saved in other formats. We don't know the format of excel sheet you use, so answer is impossible. Anyway you didn't post a code that allows to export file to the browser. – Roman C Sep 07 '16 at 17:24
  • Thank you Very much for responding. – srinivas vallap Sep 07 '16 at 19:44
  • Thank you Very much for responding, the extension with which the file is saved is xls, and note: this same code was working fine and there was no issue when this application was running on WebLogic 9.2. Only after migrating to WebLogic12c, and iPlanet 7.x, this issue has started. – srinivas vallap Sep 07 '16 at 23:36
  • Facing the same issue while migration. any update on this ?? – Bhargav Patel May 02 '17 at 11:54

1 Answers1

0

Try change:

String header = "attachment; filename=" + filename + "-"
          + new Date().getTime() + ".xls;";

to

String header = "attachment; filename=" + filename + "-"
          + new Date().getTime() + ".xlsx;";

This is a default message of Excel, because you is creating a file in the new format (.xlsx) and naming with old extension (.xls).

Guest1
  • 1
  • 1