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
11
votes
1 answer

Bolding a cell in PHPExcel leaves it selected

I am updating an Excel5 formatted spreadsheet with PHPExcel. After retrieving and setting some cells I have the following code: $objPHPExcel->getActiveSheet()->getStyle("A$total_row:N$total_row")->getFont()->setBold(true); The range of cells does…
George
  • 934
  • 2
  • 10
  • 21
11
votes
1 answer

How do I get a range of cells in PHPExcel?

I am using PHPExcel to read some data from an xls file. I want to get a couple of cells at once, say: A6 - A11. I know I can use $cell = $objPHPExcel->setActiveSheetIndex(0)->getCell('A6'); to get a single cell, and I could probably loop through an…
hitautodestruct
  • 20,081
  • 13
  • 69
  • 93
11
votes
1 answer

hyperlink on Text in cell using phpExcel

$objPHPExcel->setActiveSheetIndex($i)->getCell('A' . $j) ->getHyperlink('mytext') ->setUrl('http://abc.com'); i am trying to link a specific part of text in cell, but its linking to a whole cell, is there any solution to do it? OR if i do it with…
Jabeen
  • 357
  • 2
  • 4
  • 15
11
votes
2 answers

Why am I getting an "invalid or unitialized Zip object" error when trying to read excel file via PHP?

I would like to find out how to read an excel file using via PHP. My specific use case is using PHPExcel from within Yii. I have followed numerous tutorials and I am always stuck at one point: "ZipArchive::getFromName(): Invalid or unitialized Zip…
rodrigue
  • 125
  • 1
  • 1
  • 6
11
votes
2 answers

Conditional Formatting lost on save

I'm trying to create a simple setup to load a template, insert some data and save as a new file. However I need some conditional formatting on some of the cells and when I get the newly created files the conditional formatting is missing. It's not…
CyanAngel
  • 1,240
  • 1
  • 14
  • 28
11
votes
1 answer

PHPExcel how to apply alignment for the whole document created from mysql table

I used PHPExcel library to generate excel files based on the table created by the mysql query. I created multiple tabs with individual data from different queries. I need to align the data in the all the cells in all the tabs (worksheets) to…
user1702273
  • 123
  • 1
  • 1
  • 6
10
votes
3 answers

Load excel file into PHP_Excel from variable

I currently have this file_put_contents($tmpfile, $attachments[0]['body']); $objPHPExcel = PHPExcel_IOFactory::load($tmpfile); The file I am reading is extracted from an email, so rather then writing it to a tempfile I would like to read it…
bumperbox
  • 10,166
  • 6
  • 43
  • 66
10
votes
1 answer

PHPExcel: Read all values (date, time, numbers) as strings

I am facing issues with dates and time. I want them to be read just like they appear in the excel workbook. So, I believe if I get all cells of the sheet using toArray(), then I should simply do something (some format conversion) that will map all…
WebSoft
  • 103
  • 1
  • 1
  • 5
10
votes
1 answer

PHPExcel - read time value from a cell

I'm loading an Excel file that has cells with time data, e.g. 08:00:00. But when I try to read those cells with getValue(), it returns some floating point numbers instead of the actual time (in case of 08:00:00, it returns 0.3333333). Here's my…
kolufild
  • 712
  • 1
  • 9
  • 20
10
votes
1 answer

PHPExcel will not export to CSV

I am banging my head against a wall trying to figure out why I cannot get PHPExcel to output a csv file. Oddly enough, this works in Internet Explorer- it outputs as csv, but in every other browser I try it outputs it as an xls that Excel refuses to…
floppyraid
  • 145
  • 1
  • 1
  • 9
10
votes
2 answers

How to middle align cell value in PhpSpreadsheet?

I want to align the cell value to the middle. My output looks like this:- My expected output should be this: I want every column to be in the center. I tried the following code: $styleArray = [ 'font' => [ 'bold' => true, ], …
kunal
  • 4,122
  • 12
  • 40
  • 75
10
votes
3 answers

phpExcel write long number in cell

While writing the excel file is fine I see that really long numbers are formulas in excel Example: 8.71129E+12 instead of: 1234567890 How can I change the format during the PHP Excel Creation? I'm following the simple example here
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
10
votes
4 answers

PhpSpreadsheet - get row without iterating on each cell

I'm using PhpSpreadsheet to easily read from a xls document and insert into a DB after some calculations. I succeeded using examples from the documentation, but I find it sooo complicated I'm sure I missed something and it can be done much more…
Jeremy Belolo
  • 4,319
  • 6
  • 44
  • 88
10
votes
1 answer

PHPExcel reader -- help required

I m using PHPExcel to read data from Excel sheet and store in mysql table, till now i m able to upload .xls as well as .xlsx file and after uploading the xls i got below table structure of data name start_date end_date …
xkeshav
  • 53,360
  • 44
  • 177
  • 245
10
votes
1 answer

PHPExcel Cells over lapping each other >setRowHeight(-1) auto cell height not working

Update Tested using PHPSpreadsheet I have this code below that I have tried. It seems to work on MSOffice Excel if I use xls when I write the file. Note not working with Libre Office does not auto resize row need it to work with libre office as…
user4419336