简体   繁体   中英

Create excel file using PHP compatible for 2007 and 2003

am creating a .xls file using PHP fopen

write and append the contents to the file. Works fine with Excel 2003.

But excel 2007 showing a alert before opening as un supported type.

If i create file with .xlsx extension , it is not opening in 2003.

Is there any standard way that works fine in both 2003 and 2007 versions .

Use PHPExcel . It's free and can read/write Excel 03/07 files directly. There's Spreadsheet_Excel_Writer in the PEAR library, but it's essentially dead and only support writing BIFF5 files, which corresponds to Excel '95 ('97? not sure...)

I bet he wants to to the same thing I want: create a tab-delimited file (instead of comma-delimited), to avoid dealing with apostrophes or commas with the cells. Just $field_contents . "\\t" . $next_field_contents

We know that if we create a comma-delimited file with extension CSV the browser will send it to Excel (somehow). What I want (and the questioner probably wants) is a way to:

  1. produce a TAB-delimited file
  2. have the browser tell the operating system to have Excel open it
  3. (but not ask the user any questions, eg, about formatting)

Those who do not know how to do this, please shush! But if anyone knows whether this is possible or not, please speak up!!!!

If you don't need any formatting or even multiple sheets the easiest thing to do is to just create a comma-separated file. (.csv) 2003 and 2007 can open those just fine. It's also much easier to deal with in PHP

What format are you actually writing? Writing an Excel file isn't simply a matter of giving an arbitrary file an extension of xlsx or xls.

For commonality, you can write a BIFF5 or BIFF8 xls file (all versions of Excel post 95 will read this), or there is the Excel 2003 XML format, which can be opened by both Excel 2003 and Excel2007 (and Excel 2010 as well).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM