How can i write data into an excel using PHP

前端 未结 6 453
南方客
南方客 2020-11-27 20:23

Is it possible to append content to an .xls file using PHP fwrite()?

When i try this using fwrite(), the resulting file causes an error message in Excel 2007.

<
相关标签:
6条回答
  • 2020-11-27 20:45

    You can use the PhpSpreadsheet library, to read an existing Excel file, add new rows/columns to it, then write it back as a real Excel file.

    Disclaimer: I am one of the authors of this library.

    0 讨论(0)
  • 2020-11-27 20:52

    you can try this library http://phpexcel.codeplex.com/

    or you can create .csv file for example and then import them to excel.

    0 讨论(0)
  • 2020-11-27 20:53

    if you just want/need to create a very simple table, you just need to make a *.csv-file which can be opened by excel - but not: you can't use formulas in this and you can't do any kind of formatting.

    0 讨论(0)
  • 2020-11-27 20:58

    I wrote a simple library for exporting Excel-friendly XML files from PHP: http://github.com/elidickinson/php-export-data

    0 讨论(0)
  • 2020-11-27 21:02

    You can try and create a CSV file, like this:

    name;surname;blabla
    name;surname;blabla
    name;surname;blabla
    name;surname;blabla
    

    Excel should eat this :)

    It is convenient to use PHP CVS functions: http://php.net/manual/en/function.fputcsv.php

    0 讨论(0)
  • 2020-11-27 21:04

    to write you can use : Spreadsheet_Excel_Writer is a tool for creating Excel files without the need for COM components

    http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.php but you cant appaend to file , only to create it.

    or using phpexcel (support excel 2007)

    http://phpexcel.codeplex.com/

    and you can append see a example :

    http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=82996

    0 讨论(0)
提交回复
热议问题