treehouse : what would you like to learn today?
Web Design Web Development iOS Development

HTML Table to Excel

  • Hello all,

    I am having a webpage which contains an HTML table which is populated through PHP dynamically. I want the users to export this specific table (Not all tables) to excel file, and then may be they will be able to save it on there disk. I don't know how to do it. I even don't know where to start. Please guide me through ..

    Thanks.
  • Your best bet would be to write the data out into a text file. Name the file whatever.csv and put a comma between the fields that you write out.

    There you have a CSV file. Which, although not strictly an Excel formatted file will open in Excel.
  • If you wan't to be simple, just write it as CSV file.
    If you need more features, try PHPExcel, it's a PHP class that generate/parse MS excel format with PHP.