Questions tagged [phpexcel]

A PHP library to create, read, edit and write spreadsheet files for MS Excel and other spreadsheet programs

PHPExcel was a library written in pure PHP that provides methods to read workbook files generated by Excel and other spreadsheet programs (Excel 95 and higher .xls and .xlsx, Excel 2003 XML, Comma-Separated Value, SYLK, Gnumeric, and Open/Libre Office Calc .ods); to manipulate spreadsheet data and formatting; and to create/write to various formats (Excel BIFF8 .xls, Excel 2007 .xlsx, Comma-Separated Value, HTML, and PDF).

It is a component of the PHPOffice suite of libraries, comprising PHPExcel, PHPWord, PHPPowerPoint, PHPProject and PHPVisio.

The last production release of PHPExcel was version 1.8.1 in year 2015 via composer and git.

The final notice from PHPExcel is:

The project has not be maintained for years and must not be used anymore. All users must migrate to its direct successor PhpSpreadsheet, or another alternative.

Popular questions

Resources

Documentation

3639 questions
46
votes
3 answers

Merge Cell values with PHPExcel - PHP

I have a simple table like: - id - first_name - last_name - email - phone I'm using PHPExcel to export my data in XLS format $rowNumber = 1; while ($row = mysql_fetch_row($result)) { $col = 'A'; foreach($row as $cell)…
Cheerio
  • 1,260
  • 6
  • 19
  • 37
45
votes
6 answers

How to find out how many rows and columns to read from an Excel file with PHPExcel?

With the following code, I am able to read the cells out of an Excel file with PHPExcel. I currently manually define how many rows and columns to read. Is there a way that PHPExcel can tell me how many rows and columns I have to read to get all the…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
45
votes
5 answers

failed to delete buffer. No buffer to delete

I am trying to generate an excel file with the extension .xlsx from the code below. I am able to download the file very well but when I open it with excel sheet, I receive the following warning error .. Excel cannot open the file 'dindi.xlsx'…
H Dindi
  • 1,484
  • 6
  • 39
  • 68
44
votes
3 answers

PHPExcel: Setting font size?

I have been looking to change the font size of some Excel cells using a PHP library called PHPExcel. This is what I tried: $objPHPExcel->getActiveSheet()->getStyle("F1:G1")->getFont()->setFontSize(16); The method above does not work. I was…
AnchovyLegend
  • 12,139
  • 38
  • 147
  • 231
43
votes
6 answers

How to automatically read in calculated values with PHPExcel?

I have the following Excel file: I read it in by looping over every cell and getting the value with getCell(...)->getValue(): $highestColumnAsLetters = $this->objPHPExcel->setActiveSheetIndex(0)->getHighestColumn(); //e.g. 'AK' $highestRowNumber =…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
41
votes
7 answers

How to get the number of columns of worksheet as integer (28) instead of Excel-letters ("AB")?

Given: $this->objPHPExcelReader = PHPExcel_IOFactory::createReaderForFile($this->config['file']); $this->objPHPExcelReader->setLoadSheetsOnly(array($this->config['worksheet'])); $this->objPHPExcelReader->setReadDataOnly(true); $this->objPHPExcel =…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
36
votes
6 answers

How to use PhpSpreadsheet without installation (like PHPExcel)

According to the PhpSpreadsheet Doc it's neccessary to install it with composer. In my case I just have a webspace without Terminal but Plesk. Is it anyway possible to use PhpSpreadsheet, like it is with PHPExcel where you just have to place the…
MaggusK
  • 605
  • 1
  • 8
  • 12
35
votes
7 answers

PHPExcel Column Loop

How can I do a loop which based on Excel worksheet columns? I found (and used) WorksheetIterator, RowIterator and CellIterator but nothing about columns.
Hazard
  • 760
  • 1
  • 6
  • 16
34
votes
5 answers

PHPExcel - creating multiple sheets by iteration

I'm trying to create multiple sheets by iteration in phpexcel: $i=0; while ($i < 10) { // Add new sheet $objWorkSheet = $objPHPExcel->createSheet(); // Attach the newly-cloned sheet to the $objPHPExcel…
Chris
  • 1,316
  • 2
  • 13
  • 20
34
votes
1 answer

How to open an Excel file with PHPExcel for both reading and writing?

I'm using the PHPExcel library, and I'm creating xls objects either for writing or for reading: PHPExcel_IOFactory::createReaderForFile('file.xlsx') PHPExcel_IOFactory::createWriter('Excel2007') How can I open an XLSX file for reading and…
Petruza
  • 11,744
  • 25
  • 84
  • 136
34
votes
3 answers

CSV Export/Import with PHPExcel

Could you please guide me or provide me with some sample codes for performing CSV export and import using the PHPExcel library? Excel export and import is fine but I need CSV export/import as well. I have other means of CSV export and import, but…
Kunal
  • 1,440
  • 4
  • 14
  • 37
34
votes
1 answer

Is there a method in PHPExcel to write a PHP array directly into a row?

I understand that I'll need to write a loop inside which I use SetCellValue('cell_name', 'value'); but is there a method in PHPExcel that just accepts a single array and writes that into an Excel sheet row? Something like: $testArray =…
Aditya M P
  • 5,127
  • 7
  • 41
  • 72
31
votes
3 answers

How to read large worksheets from large Excel files (27MB+) with PHPExcel?

I have large Excel worksheets that I want to be able to read into MySQL using PHPExcel. I am using the recent patch which allows you to read in Worksheets without opening the whole file. This way I can read one worksheet at a time. However, one…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
31
votes
1 answer

How to do the phpexcel Outside Border

I use the below code for All Borders $BStyle = array( 'borders' => array( 'allborders' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN ) ) ); Here i use…
ABD
  • 869
  • 2
  • 12
  • 28
30
votes
2 answers

How do I write my excel spreadsheet into a variable, using PhpExcel?

After loading a PHPExcel object with my data, I want to output the contents directly into a php variable, instead of writing to a file. Have I missed the method to do that, for it seems that the only way to save is to save to disk.
Aaron
  • 605
  • 1
  • 9
  • 19