Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • May 26 13:51

    MarkBaker on Minor-Documentation-Updates


  • May 26 13:50

    MarkBaker on PhpStan-Cleanups


  • May 26 13:44
    MarkBaker closed #2529
  • May 26 13:28

    MarkBaker on master

    Declare a few return datatypes Merge pull request #2857 from P… (compare)

  • May 26 13:28
    MarkBaker closed #2857
  • May 26 13:28

    MarkBaker on master

    Declare a few return datatypes Merge pull request #2858 from P… (compare)

  • May 26 13:28
    MarkBaker closed #2858
  • May 26 13:24
    MarkBaker opened #2858
  • May 26 13:24

    MarkBaker on PhpStan-Cleanups


  • May 26 13:22
    MarkBaker opened #2857
  • May 26 13:21

    MarkBaker on Minor-Documentation-Updates

    Declare a few return datatypes Declare a few return datatypes (compare)

  • May 26 12:48
    Laurezi starred PHPOffice/PhpSpreadsheet
  • May 26 09:21
    GiovanniMet starred PHPOffice/PhpSpreadsheet
  • May 26 06:05
    JorgeDevmm starred PHPOffice/PhpSpreadsheet
  • May 26 05:13
    oleibman labeled #2856
  • May 26 05:09
    oleibman opened #2856
  • May 26 02:00
    CryptoDev33 starred PHPOffice/PhpSpreadsheet
  • May 26 01:14
    roelmagdaleno starred PHPOffice/PhpSpreadsheet
  • May 25 21:21
    WeTruck closed #2855
  • May 25 21:21
    WeTruck commented #2855
is there a way to set custom linear gradient colors to PHPspreadsheet pie chart?
i only managed to set custom colors
Hello all, is anyone onow how to modify the cell value depend on id from another cell?
Something like if A1 = foo, and set cell value on B1 = bar
Sergey Popov

Hey, guys! I have a big problem with an corrupted xls file. And I could not understand why.

Code is as simple as i sent earlier

i used following code and chart is created but without data so please help me
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile("Flow Balance Worksheet APP Development 01032022.xlsx");
$spreadsheet = $reader->load(request()->file('file'), $reader::LOAD_WITH_CHARTS);
$sheet = $spreadsheet->getActiveSheet();
$chart = $sheet->getChartCollection();
$writer = new Xlsx($spreadsheet);
Hi there!
Hey, guys! I try to read several styles in a cell.
we can retrieve almost styles like font-size, font-family, bold, etc.. ,but can't get color.
Plz check it for me and let me know.
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($inputFileName);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
$spreadsheet = $reader->load($inputFileName);
$cellValue = $spreadsheet->getActiveSheet()->getCell('A1')->getValue();
if ($cellValue instanceof \PhpOffice\PhpSpreadsheet\RichText\RichText) {
foreach ($cellValue->getRichTextElements() as $richTextElement) {
if ($richTextElement->getFont()) { var_dump($richTextElement->getFont()->getColor()->getRGB()); }
Norberto Capalbo
Hi, I have problem with excel generation PHPSpreadsheet when i try to download the excel, excel cant open for invalid format.

$nombreDelDocumento = "Descarga_paqar.xlsx";

Crear un "escritor"

$writer = new Xlsx($documento);

Le pasamos la ruta de guardado

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $nombreDelDocumento . '"');
header('Cache-Control: max-age=0');
$writer = IOFactory::createWriter($documento, 'Xlsx');

hi everyone
can anyone help me link my phpspreadsheet output to phpmailer without downloading the xlsx file
6 replies


I have found that the useful Excel tables feature is missing in the PHPSpreadsheet library. Issue PHPOffice/PhpSpreadsheet#1816.

After some research on how the feature is implemented in exceljs, I'm planning to contribute on adding this feature to PHPSpreadsheet.

I'm here seeking any advice from the team before start working. If I file a pull request, will it merge?

Overview of Excel tables

Reasons to use Excel Tables

1 reply

any idea what causes this error? Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Reader\Exception: Parameter pos=-12 is invalid

$inputFileName = "excel.xls";
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls');
$spreadsheet = $reader->load($inputFileName);

file: https://filebin.net/sle19tm0kdgduyne/excel.xls?t=u0itbeue

Hi Alex, I am not sure if you can remember how you resolved this issue? Parameter pos=-12 is invalid

$reader = PhpOffice\PhpSpreadsheet\IOFactory::createReader($ext);
$spreadsheet = $reader->load($file);
// Export to CSV file.
$writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv');
$writer->setSheetIndex(0); // Select which sheet to export.
$writer->setDelimiter(';'); // Set delimiter.
Hey, I have a quick question. Must Excel be installed on the system on which you want to create an Excel file with PhpSpreadsheet?
5 replies
Manish Jain
Hi , i am importing style data from an excel to php and running into an error with the background color, I get 'ffffff' even thou the background is set to "No Fill".
Q. Any way to differentiate between White bg and No Fill bg when reading from file ?

How can I display a formatted time range in an Excel worksheet?

I have a range of 25:30 hours that I would like to show using HH:MM:SS format, but if I use the code below it shows as 01:30:00.

$seconds = 91800;
$spreadsheet->getActiveSheet()->setCellValueExplicit('L' . $row, (seconds / 86400) , PHPExcel_Cell_DataType::TYPE_NUMERIC);

4 replies
Is that possible to lock a xlsx file? I mean lock by password when a user tries to open the file. locked to read, not locked to write.
I found few functions to add a password but it's only for write permission and not read permission
1 reply
Hi, is it possible to adjust the horizontal scrollbar width with phpspreadsheet?
3 replies
hello guys,how to set limit to output data when i try to read excel data ,i need to set pagination,cant set limits ,how to resolve that?and i need to display the data as html in browser.,without null values.

hello guys,how to set limit to output data when i try to read excel data ,i need to set pagination,cant set limits ,how to resolve that?and i need to display the data as html in browser.,without null values.

Why don't u save the data in other place from excel, so u can paginate it easily.

which data type do u prefer?

which data type do u prefer?

Mysql, Tidb , ElasticSearch or Redis

but my problem is i need same color what I used in spreadsheet,
is it possible ?
but my problem is i need same color what I used in spreadsheet,
U can store the color attribute as well, then send the all data including color to front end
U see the content that browser display is back-end returned
I think u can understand what i say
yes,thank you.

Hi i need to show dropdown of country,state,city
based upon dropdown values should reflect,also address,streeet input box should show and hide can anyone tell me how to do using spreadsheet?


Here is the doc above

1 reply
Hi,i need to show/hide rows based upon the dropdown values
1 reply
Hello Everyone
Can you help me with a code to update a cell value without changing the other values or create a new file ?
1 reply
Brock Jameson
Hey everyone, I'm trying to save a xlsx file inside of my module and then trying to use this library to manipulate the spreadsheet data but am having trouble importing my xlsx file in the php code - I just get a "vcards.xlsx" does not exist. Any ideas on best way to access spreadsheets that are in version control?
2 replies
how to export existing template without losing style?
9 replies

how to export existing template without losing style?

Do u refer to the documention here?

Golden Dev
Hello Everyone
How to copy style of cell by range?
It's working well when copy only one cell, but not working with range
Anh Le VN.Hanoi
Hi, has the issues with drop-lists and buttons been resolved yet? The xlsx files that I'm getting from $speadsheet->save() do not have any legacy drawing elements that the original has

php7. 3 version of Excel table export prompts that the web page may not be connected temporarily, or it has been permanently moved to the new web address. Do you know why?



Hi Everyone

I am having some issues when using getCalculatedValue. Some cells work okay in retrieving the value, but some other simply copies the formula.
Here's what I am trying to do
I want to copy the values in sheet "kirim SAP" (hidden sheet), to a separate new file. So formula containing sheet references need to be calculated before set in the new file.
Here's the source file.

Here's the output on the new file. Please mind that I expect new rows in this file for each trigger.

is there something i need to do to make it work? I checked the doc for supported formulas https://phpspreadsheet.readthedocs.io/en/latest/references/function-list-by-name/, but all that we used seem to be supported

Here's a snippet of my code to achieve this.

        $sheet = $spreadsheet->getActiveSheet();
        $highestColumn = $sheet->getHighestColumn();
        $highestRow = $sheet->getHighestRow();


            $stInsertData = $connection->prepare("insert into asmt_report_result values(DEFAULT, :template, :participant, :fields);");
            $successInsertData=$stInsertData->execute(array(':template'=>$_GET['template'], ':participant'=>$_GET['participant'],':fields'=>json_encode($arr)));

        }catch(Exception $e){
            throw $e;


        $spreadsheet2 = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

            //echo "file exists";
            $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
            $spreadsheet2 = $reader->load("../my_tmp/scpuserhris/".$randomName.".xlsx");
            //echo "file not exist";

        $sheet2 = $spreadsheet2->getActiveSheet();

        $highestRow = $sheet2->getHighestRow();

            $sheet2->setCellValue($lastColumn.$highestRow, $lastColumn=='A'&&empty($arr[$lastColumn.'2'])?'0':$arr[$lastColumn.'2']);
            //echo $lastColumn.$highestRow."=".$arr[$lastColumn.'2']."<br/>";

        $writer2 = new Xlsx($spreadsheet2);

        $filePath2 = "../my_tmp/scpuserhris/".$randomName.".xlsx";
3 replies