3

Good Morning,

I am use a API JASPER "JasperClient.php" where i use the function runReport to return a xls and in php code i want to download Excel File from the server.

Setting the header:

header('Content-type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename=myfile.xls');

When i'm download the file and try to open the says:

The file you are trying to open, 'filename.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 the file. Do you want to open the file now?

Can you help me please? Thank you .

user2968390
  • 43
  • 1
  • 2
  • 6
  • easy check: can a proper microsoft excel open the file you're trying to send? if yes, the problem is in your download, if no, the problem is in your file. Creating excel files isn't very easy. – STT LCU Nov 08 '13 at 10:10
  • 1
    Are you creating an actual MS Excel BIFF format file; or simply a csv file, or html markup, and just giving it an .xls extension ? – Mark Baker Nov 08 '13 at 10:11
  • I don't understand: you preview the report in iReport but you create the Excel file in php? Jasper is written in Java and IIRC uses POI to generate Excelfiles, so I don't understand where php comes into the picture... – fvu Nov 08 '13 at 10:21
  • no the microsoft excel can't open the xls file , but the excel preview in jaspersoft can! – user2968390 Nov 08 '13 at 10:22
  • Perhaps if you showed how you're creating the file, or at least indicated which library you're using to create it – Mark Baker Nov 08 '13 at 10:26
  • You'll have to explain that procedure a bit more in detail, are you saying here that you have php code that transforms jrxml into xls? You should probably add your (php) code to show us what's going on... – fvu Nov 08 '13 at 10:27
  • I rephrased the question ... – user2968390 Nov 08 '13 at 11:07

1 Answers1

2

Are you creating Excel 2007 files? If so try using mimetype application/vnd.openxmlformats-officedocument.spreadsheetml.sheet and file extension .xslx

Jonas
  • 106
  • 6