Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
@MarkBaker I feel so dumb, the function works fine, I how ever, don't work fine as I forgot to import PHPSpreadsheet. After I imported it it worked fine.
anyone knows if phpspreadsheet supports poisson.dist calculations?whenever i try to get a cell calculated field with Poisson ,script crashes.
Fräntz Miccoli
@akalogiros find . |grep -s POISSON comes back empty handed so I guess it's not
Rubén Rubio


I am trying to read a XLS spreadsheet and I want all values to be strings, i.e., I do not want them to cast to any type. The problem I have is that I have some large numbers that are EAN codes, and the readers converts them to float with scientific notation, therefore, not valid numbers. For example, I have the code 123456789012345000 that is read as 1.2345678901234E+17.

I have tried many options to achieve this, trying to use a custom ValueBinder, as it seems the most legit option. This is the code I have:

$binder = new class extends DefaultValueBinder {
    public function bindValue(Cell $cell, $value)
        $cell->setValueExplicit($value, DataType::TYPE_STRING);
        return true;


$reader = IOFactory::createReaderForFile($path);
$spreadsheet = $reader->load($path);

$rows = $spreadsheet->getActiveSheet()->toArray(null, false, false);

No matter what I try, I can not get it to work, it never goes through my ValueBinder, and I have not found anything in the documentation. Any help?

Thank you!

Fräntz Miccoli
@rubenrubiob I don't know the innerworkings of setValueExplicit but the casting of your value to string it probably the normal one in PHP. Check this https://stackoverflow.com/questions/1471674/why-is-php-printing-my-number-in-scientific-notation-when-i-specified-it-as-00 you might find a few useful hints.
Rubén Rubio

Yes, I know that that happens. The thing is that I lose precision in the number. For example, 123456789012345000 becomes "123456789012344992.000000" when I do an sprintf('%f', $var). But it is not a number, it is a string, and I want it to be read as string in the beginning; if it is read as a string and not as a number, I think I will be able to solve the problem.

I will keep looking for a solution.

Thanks for your answer @frantzmiccoli !

Another thing is that the reader never calls my ValueBinder, so line

$cell->setValueExplicit($value, DataType::TYPE_STRING);

is never called.

Fräntz Miccoli
never used that, no clue
When I used phpspreadsheet to load excel, I found that it read the calculation formula filled in the form. Is there any way to read the final value of the form? thx
Judah Wright
Howdy folks!
I am working on a problem and my google-fu is not cutting it. The gist is I need to make sure that text does not overflow a cell, with the problem being that I am using merged cells and Excel does not support auto-height with merged cells. SO, is there a simple way to check if the text in a given cell is overflowing? If so I could increment the row height until all text is visible.
@PowerKiKi thanks for u help!
Tolga Ozses
I have an issue, and it would be too long to describe it here. I'm wondering if it's a bug. Would anyone be so kind to look at https://drupal.stackexchange.com/q/275922/17632 ?
Adrien Crivelli
@kartagis not a bug in PhpSpreadsheet. You are most likely not giving a path on disk to an existing file, but instead giving some sort of URL or custom Drupal path references
Tolga Ozses
@PowerKiKi it was a typo on my side. I used ::createReaderFromFile($uri) and ::load($filename)
Fräntz Miccoli
@MarkBaker do you think you would have time to give a look at? PHPOffice/PhpSpreadsheet#844 (see also PHPOffice/PhpSpreadsheet#818 )
hello anyone there?
need help to setup phpspreadsheet with codeigniter
Khine Wai Oo

Hello? Anyone in here?
I setup the page my excel file with Page Layout view and width.
getSheetView()->setView(SheetView::SHEETVIEW_PAGE_LAYOUT) and

The problem is that I start the excel with Microsoft 2007, Pagesetup width is not work.
When I click anything in menu of excel.
Pagesetup width is work.

Is it problem of Excel or Is there any code to solve that problem?

When I use $writer->save($filename); on wich location is saving file?

When I use


I get following error

Could not close zip file /wp-content/uploads/exports/prova.xls.


Is there a way to apply a border style for a range of cells other than the default method :


This method applies the border for the whole block and not each cell

Fräntz Miccoli
@Med-Seif I am pretty sure you have utilitary function than could give you a cell array from a cell range. like A1:E10 --> ['A1', 'A2', ...]

@Med-Seif I think you may find this helpful: https://phpspreadsheet.readthedocs.io/en/develop/topics/recipes/#styles
You can use allBorders like

$stlyes = [
  'borders' => [
        'allBorders' => [
            'borderStyle' => Style\Border::BORDER_THICK,

This will apply border to each cell in the range you have selected, rather than to just the outer cells.

Miguel Ángel Sánchez Palafox
Hello, there is a way to format as a table?
Angelo D'Errico
Hello, there is anyone that solved secondary Y-Axis for Charts?
@IPMegladon Hi, have you solved your issue on secondary Y-Axis?

Hello all,

Is there any way to open a password protected excel file? Given the password always be the same. (Or it is better i can pass/key in the password to open the file).


No I haven't I wasnt able to fully understand the implementation of the axis and
Therefore couldnt write the code for reading and writing the secondary axis as well
@amosfolz Thank you, that helped me a lot, I found that I wanted from The additional shortcut borders in addition to allBorders : horizontal, vertical etc...
@frantzmiccoli Thank you, that should be interesting but I prefer apply a style on a range of cells performance needs
Hi, we are trying to modify an excelsheet with PhpSpreadsheet but we are having issues with the LINEST formula not behaving the way it does in excel. In Excel it is possible to set a multidimensional array like this: =LINEST(T41:T51;K41:L51;1;1), however PhpSpreadsheet seems to require that both arrays are the same size. Is there a way to work arround this limitation?
Hi! Is there a known problem with PhpSpreadsheet loading xlsx files with a chart sheet? I have a very simple file with only two sheets, one with the data (3 numbers), and the other sheet is a pie chart of those 3 numbers (not as object in a sheet - the whole second sheet is a chart). When I try to read the file, I get a Notice: Undefined index: rId2 in phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php on line 754. If the chart is as object in a normal sheet, the problem does not occur. Any clues/workarounds? Versions: PhpSpreadsheet 1.6, PHP 7.1.12, xlsx file created with Excel 2011 for Mac. Thanks!
(The Notice itself doesn't disturb me much, but the fatal error it causes does: Uncaught TypeError: Argument 1 passed to PhpOffice\PhpSpreadsheet\Reader\Xlsx::readColumnsAndRowsAttributes() must be an instance of SimpleXMLElement, boolean given)
Hi Guys :) just wanna ask if anybody here was able to make the axis labels overlapping?Thanks in advance. BTW im trying it on a bar graph :)
Tolga Ozses
Luis Bessa
hello, is it possible to set a range of cells as a table ? i failed to find information about it
Flávio Alves
Hey guys, I can easily insert an image inside a sheet and at specific cell coordinates, but how can I set the cell dimensions to fit the image dimension?
Mark Baker
@PowerKiKi How do we push the documentation from /docs in the github repo to phpspreadsheet.readthedocs.io?
Adrien Crivelli
@MarkBaker docs are published automatically on every single push. It was stuck for a while because I forgot to remove the develop branch. It now correctly builds from master branch as expected.
@MarkBaker If you create an account, and give me your username, I'll gladly add you as a third maintainer, so you can access everything, and we can reduce the bus factor
Mark Baker
Thanks, I wasn't sure that the push was automatic, because I didn't see the first changes that I merged to master appearing in the docs... I'll set myself up with an account on readthedocs today
I'll also be looking at doing a tagged release over the coming week