skip to content

 Web design 

Database-driven systems

Easy-to-maintain web sites


 



Excel Read and Write

Questions often come up about reading Excel files into a PHP program and saving to Excel from PHP. You can do both and here is the info on how to do it.

Reading from Excel 
There are some good resources available that make it pretty easy to read from an Excel .xls or .csv file. More often than not, the objective is to load the spreadsheet content into a database table. The options are as follows:

  • PHPMyAdmin (open source)
    You can run this locally and most / all web hosts provide it as a tool to manage MySQL databases. If your objective is to import into a MySQL table, then you can do it from a .csv or .xls file. 
     
  • Excel_to_DB (Development in progress)
    This is a utility that I built for my own use with the excel reader on the back end (see next item). It can compare spreadsheet content with a MySQL database table and upload into a MySQL table. It has capabilities that go beyond other similar utilities. You can customize it through a parms module so it can be provided to a user to upload one or more spreadsheets. This may be released commercially once it is complete. 
    To see more details click here.
     
  • PHP-Excel-Reader (open source)
    This is a good open source facility / class that can read a worksheet from an Excel (compatible) workbook and provide you with the details in a PHP program. It can also display the worksheet with formatting for you if that is all you need. To see the documentation and download the module go to:
    Excel Reader

  • PHPExcel (open source)
    This provides a number of classes for reading and writing to Excel and other formats from PHP. I have not used these facilities but it seems to be an active project with a good range of capabilities.
    PHPExcel

Writing to Excel
This can be easily accomplished with Header statements. For my utility routine that does this go to:
Desktop Write


 

 
   

Powered by Website Baker,
Design by Innovations Design based on a template by gavjof