Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading an Excel file in PHP [closed]

I'm trying to read an Excel file (Office 2003). There is an Excel file that needs to be uploaded and its contents parsed.

Via Google, I can only find answers to these related (and insufficient topics): generating Excel files, reading Excel XML files, reading Excel CSV files, or incomplete abandoned projects. I own Office 2003 so if I need any files from there, they are available. It's installed on my box but isn't and can't be installed on my shared host.

Edit: so far all answers point to PHP-ExcelReader and/or this additional article about how to use it.

like image 448
Dinah Avatar asked Feb 19 '09 01:02

Dinah


People also ask

Can we read Excel file in PHP?

PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc. In this tutorial, we are going learn how to read and write the xlsx file. You can integrate it with your database if you need.

How do you read and write Excel file in PHP?

- It can Read and Write excel files in php, also, it can create PDF documents and Charts. - $objectClass is the object instance of the class. - $excel->sheets[0]['numRows'] contains the number of rows with data in first sheet. - $excel->sheets[0]['numCols'] contains the number of columns with data in first sheet.


2 Answers

You have 2 choices as far as I know:

  1. Spreadsheet_Excel_Reader, which knows the Office 2003 binary format
  2. PHPExcel, which knows both Office 2003 as well as Excel 2007 (XML). (Follow the link, and you'll see they upgraded this library to PHPSpreadSheet)

PHPExcel uses Spreadsheet_Excel_Reader for the Office 2003 format.

Update: I once had to read some Excel files but I used the Office 2003 XML format in order to read them and told the people that were using the application to save and upload only that type of Excel file.

like image 167
Ionuț G. Stan Avatar answered Oct 02 '22 12:10

Ionuț G. Stan


I use PHP-ExcelReader to read xls files, and works great.

like image 21
Luis Melgratti Avatar answered Oct 02 '22 14:10

Luis Melgratti