0

I'm using a Wordpress plugin, wpdatatables, that uses PHPExcel to produce pdf, csv, and Excel file exports.

Anyway, when downloading an .xls file from my website, when I open it .. Excel gives me the error “The file format and extension of “blahblah.xls” don’t match. The file could be corrupted or unsafe. Unless you trust its source, don’t open it.”

Of course the file still opens fine, but I'd like to get rid of this error. One thing I noticed is the .CSV export is seemingly identical in all ways except the file extension, and opens without an error.

As someone who is not terribly familiar with PHP sadly, what direction should I look in to make PHPExcel produce .csv files only? Is there a specific function or directory in PHPExcel responsible for the Excel writer file output?

user45867
  • 887
  • 2
  • 17
  • 30
  • If all you want are CSV files, it doesn't make much sense to use PHPExcel. – Phylogenesis Feb 19 '15 at 17:02
  • It is possible that it is exporting in the newer XLSX file format. Try naming the file with that extension and see if the error persists. – dub stylee Feb 19 '15 at 18:02
  • I didn't elect to use PHPExcel, the original developers did. It's mostly for managing the "online data table" -- since I think they built that as a sort-of online Excel file. Anyway, I'd gladly name it as an xlsx (or csv) -- but I'm not sure where to change this in the PHPExcel files. – user45867 Feb 19 '15 at 18:34
  • Eh, looking back .. I figured it out. Turns out it wasn't in the PHPExcel library files after all, so may be case specific with this app (wpdatatables) I was using. I just control+F for .xls on a lot of .php files and eventually found it, and changed it to .csv. Worked out fine. The issue it turns out is extension hardening: http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx Apparently Excel 2013 has very strict standards on what is exactly technically a properly formatted Excel file. I think CSV format, since it opens the same, is better. – user45867 Feb 19 '15 at 19:15

0 Answers0