Giter Club home page Giter Club logo

phpspreadsheet's Introduction

PhpSpreadsheet

Build Status Code Quality Code Coverage Total Downloads Latest Stable Version License Join the chat at https://gitter.im/PHPOffice/PhpSpreadsheet

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.

PHP Version Support

LTS: Support for PHP versions will only be maintained for a period of six months beyond the end of life of that PHP version.

Currently the required PHP minimum version is PHP 8.0, and we will support that version until May 2024.

See the composer.json for other requirements.

Installation

Use composer to install PhpSpreadsheet into your project:

composer require phpoffice/phpspreadsheet

If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as php-fpm or Apache's mod_php, then you might want to add the following to your composer.json before installing:

{
    "config": {
        "platform": {
            "php": "8.0"
        }
    }
}

and then run

composer install

to ensure that the correct dependencies are retrieved to match your deployment environment.

See CLI vs Application run-time for more details.

Additional Installation Options

If you want to write to PDF, or to include Charts when you write to HTML or PDF, then you will need to install additional libraries:

PDF

For PDF Generation, you can install any of the following, and then configure PhpSpreadsheet to indicate which library you are going to use:

  • mpdf/mpdf
  • dompdf/dompdf
  • tecnickcom/tcpdf

and configure PhpSpreadsheet using:

// Dompdf, Mpdf or Tcpdf (as appropriate)
$className = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class;
IOFactory::registerWriter('Pdf', $className);

or the appropriate PDF Writer wrapper for the library that you have chosen to install.

Chart Export

For Chart export, we support following packages, which you will also need to install yourself using composer require

  • jpgraph/jpgraph (this package was abandoned at version 4.0. You can manually download the latest version that supports PHP 8 and above from jpgraph.net)
  • mitoteam/jpgraph - up to date fork with modern PHP versions support and some bugs fixed.

and then configure PhpSpreadsheet using:

// to use jpgraph/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
//or
// to use mitoteam/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class);

One or the other of these libraries is necessary if you want to generate HTML or PDF files that include charts; or to render a Chart to an Image format from within your code. They are not necessary to define charts for writing to Xlsx files. Other file formats don't support writing Charts.

Documentation

Read more about it, including install instructions, in the official documentation. Or check out the API documentation.

Please ask your support questions on StackOverflow, or have a quick chat on Gitter.

Patreon

I am now running a Patreon to support the work that I do on PhpSpreadsheet.

Supporters will receive access to articles about working with PhpSpreadsheet, and how to use some of its more advanced features.

Posts already available to Patreon supporters:

  • The Dating Game
    • A look at how MS Excel (and PhpSpreadsheet) handle date and time values.
  • Looping the Loop
    • Advice on Iterating through the rows and cells in a worksheet.

And for Patrons at levels actively using PhpSpreadsheet:

  • Behind the Mask
    • A look at Number Format Masks.

The Next Article (currently Work in Progress):

  • Formula for Success
    • How to debug formulae that don't produce the expected result.

My aim is to post at least one article each month, taking a detailed look at some feature of MS Excel and how to use that feature in PhpSpreadsheet, or on how to perform different activities in PhpSpreadsheet.

Planned posts for the future include topics like:

  • Tables
  • Structured References
  • AutoFiltering
  • Array Formulae
  • Conditional Formatting
  • Data Validation
  • Value Binders
  • Images
  • Charts

After a period of six months exclusive to Patreon supporters, articles will be incorporated into the public documentation for the library.

PHPExcel vs PhpSpreadsheet ?

PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.).

Because all efforts have shifted to PhpSpreadsheet, PHPExcel will no longer be maintained. All contributions for PHPExcel, patches and new features, should target PhpSpreadsheet master branch.

Do you need to migrate? There is an automated tool for that.

License

PhpSpreadsheet is licensed under MIT.

phpspreadsheet's People

Contributors

agopaul avatar akirapenguin avatar aswinkumar863 avatar brainfoolong avatar carusogabriel avatar ccrims0n avatar dependabot[bot] avatar dgeppo avatar fdjohnston avatar fox34 avatar frantzmiccoli avatar frost-nzcr4 avatar jean85 avatar kamazee avatar lucasnetau avatar maartenba avatar markbaker avatar masterofdeath avatar mjan4175 avatar ndench avatar oleibman avatar powerkiki avatar progi1984 avatar quix0r avatar sailormax avatar slamdunk avatar synchro avatar tiagof avatar u01jmg3 avatar xandros15 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpspreadsheet's Issues

Is it possible to memory leak?

$identify = IOFactory::identify($pathToFile);
$reader = IOFactory::createReader($identify);

$spreadsheet = $reader->load($pathToFile);

unset($reader, $identify);

$worksheet = $spreadsheet->getSheet(0);
$maxRowNumber = $worksheet->getHighestDataRow();

for($row = 1; $row<=$maxRowNumber; ++$row)
{
    $rowToArr = array();

    for($column = 0; $column <= 7; ++$column) {
        $cell = $worksheet->getCellByColumnAndRow($column,$row);
        if (!is_null($cell)) {
            $value = $cell->getValue();

            // Date/time
            if($column == 7) {
                if ($value >= 1) {
                    $value = NumberFormat::toFormattedString($cell->getCalculatedValue(), 'd:hh:mm:ss');
                }
                if ($value < 1) {
                    $value = NumberFormat::toFormattedString($cell->getCalculatedValue(), 'hh:mm:ss');
                }
            }

            array_push($rowToArr, $value);
        }
        $cell  = null;
        $value = null;
        }
}

18000 rows
8 columns
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4104 bytes) in /var/www/rgmc/administrator/components/com_muzplaylist/vendor/phpspreadsheet-dev/PhpSpreadsheet/Style/NumberFormat.php on line 477

Phone numbers in format +1234567890 are being miss-interpreted as FORMAT_NUMERIC

My CSV file looks like this:

"FirstName";"FamilyName";"PhoneNumber";"Supplier";"Birthday"
"Max";"Mustermann";"+49123456789";"csv-test";03.01.1981

The shown phone number is with current code being interpreted as FORMAT_NUMERIC. But as you can see, I have wrapped it into quotes which should mean FORMAT_STRING. This causes the correctly formatted phone number being returned as 49123456789 and not +49123456789.

If my code sees 49123456789, it auto-prepends a leading zero so the numer is being "fixed". Sadly I cannot turn leading 49 into zero because there are also valid phone numbers with 49 in pre-dial code.

So is there a clean way to force PHPSpreadsheet (same with PHPExcel!) to interpret it as FORMAT_STRING (e.g. with @ symbol being set to text)?

Cover PDF with unit tests

For now PDF examples are run by phpunit, but the 3rd party libs are not installed, so the PDF code is actually never tested. We should install those lib via composer (probably as dev deps only) and properly integrate them in the test suites.

That may involve breaking the way PDF libs are configured by end-user if everything is done via composer's autoloader.

Uncaught Error: Call to a member function attributes() on null

Hi there, here is the error i got:
PHP Fatal error: Uncaught Error: Call to a member function attributes() on null in /var/www/htdocs/syncro/V3.0/autosyncro_modules/PhpSpreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php:401

This is the xl/theme/theme.xml of the file:

but xlsx.php return:
var xmlThemeName: object(SimpleXMLElement)#99 (0) {
}

var themeName : string(0) ""

I'm using phpSpreadsheet to convert hundreds of files to csv every day, it's working well except for some of them, always the same one's.

Thank you for your help

ReadTheDocs documentation

  • Documentation/markdown/ (using as base)
  • Documentation/PHPExcel AutoFilter Reference developer documentation.doc
  • Documentation/PHPExcel Function Reference developer documentation.doc
  • Documentation/PHPExcel User Documentation - Reading Spreadsheet Files.doc
  • Documentation/PHPExcel developer documentation.doc
  • Documentation/Functionality Cross-Reference.xls

Avoid using slow in_array() when no need for NULL values

The PHP function in_array() is slow in performance compared to isset(). This has the fundamental reason that in_array() loops through the whole array an compares each key. isset() in contrast is only checking if the given key is set but it doesn't find NULL values because it cannot do this (see documentation of each functions).

I would go and rewrite PhpSpreadsheet so it uses isset() as I see no use for checking NULL values e.g. with $filterTypes in src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php. Also e.g. src/PhpSpreadsheet/Writer/Xls/Worksheet.php uses it but you can do it otherwise:

if (!isset($lockingArray[$someLock])) {
    // Do some stuff
    // Stuff is done
    $lockingArray[$someLock] = TRUE;
}

Drop PclZip in favor of built-on ZipArchive

Since PHP 5.2 ZipArchive is always available, and PclZip is a cause of bug. This can be seen in sample 20_Read_OOCalc_with_PCLZip.php, which gives the following output:

$ php samples/20_Read_OOCalc_with_PCLZip.php 
PHP Fatal error:  Uncaught Error: Call to undefined method PhpSpreadsheet\Shared\ZipArchive::statName() in /sites/PhpSpreadsheet/src/PhpSpreadsheet/Reader/OOCalc.php:73
Stack trace:
#0 /sites/PhpSpreadsheet/src/PhpSpreadsheet/IOFactory.php(251): PhpSpreadsheet\Reader\OOCalc->canRead('/sites/PhpSprea...')
#1 /sites/PhpSpreadsheet/src/PhpSpreadsheet/IOFactory.php(173): PhpSpreadsheet\IOFactory::createReaderForFile('/sites/PhpSprea...')
#2 /sites/PhpSpreadsheet/samples/20_Read_OOCalc_with_PCLZip.php(10): PhpSpreadsheet\IOFactory::load('/sites/PhpSprea...')
#3 {main}
  thrown in /sites/PhpSpreadsheet/src/PhpSpreadsheet/Reader/OOCalc.php on line 73

Fatal error: Uncaught Error: Call to undefined method PhpSpreadsheet\Shared\ZipArchive::statName() in /sites/PhpSpreadsheet/src/PhpSpreadsheet/Reader/OOCalc.php on line 73

Error: Call to undefined method PhpSpreadsheet\Shared\ZipArchive::statName() in /sites/PhpSpreadsheet/src/PhpSpreadsheet/Reader/OOCalc.php on line 73

Call Stack:
    0.0001     362960   1. {main}() /sites/PhpSpreadsheet/samples/20_Read_OOCalc_with_PCLZip.php:0
    0.0013     464544   2. PhpSpreadsheet\IOFactory::load() /sites/PhpSpreadsheet/samples/20_Read_OOCalc_with_PCLZip.php:10
    0.0013     464544   3. PhpSpreadsheet\IOFactory::createReaderForFile() /sites/PhpSpreadsheet/src/PhpSpreadsheet/IOFactory.php:173
    0.0034     603008   4. PhpSpreadsheet\Reader\OOCalc->canRead() /sites/PhpSpreadsheet/src/PhpSpreadsheet/IOFactory.php:251

So instead of debugging an obsolete, duplicated library, I suggest we drop it entirely. @MarkBaker @Progi1984 what do you think ?

Cell coordinate string can not be a range of cells

Getting this when writing to xlsx file. I guess it is only happening when there are some charts on some other worksheets.

PHP Fatal error:  Uncaught exception 'PhpOffice\PhpSpreadsheet\Exception' with message 'Cell coordinate string can not be a range of cells' in /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Cell.php:577
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php(4195): PhpOffice\PhpSpreadsheet\Cell::coordinateFromString('S147:S151')
#1 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php(502): PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet->writeCFHeader()
#2 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Writer/Xls.php(173): PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet->close()
#3 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/samples/csv_to_xsl.php(139): PhpOffice\PhpSpreadsheet\Writer\Xls->save('/Applications/X...')
#4 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/samples/csv_to_xsl.php(56): writeToSpreedshe in /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Cell.php on line 577

Fatal error: Uncaught exception 'PhpOffice\PhpSpreadsheet\Exception' with message 'Cell coordinate string can not be a range of cells' in /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Cell.php:577
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php(4195): PhpOffice\PhpSpreadsheet\Cell::coordinateFromString('S147:S151')
#1 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php(502): PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet->writeCFHeader()
#2 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Writer/Xls.php(173): PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet->close()
#3 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/samples/csv_to_xsl.php(139): PhpOffice\PhpSpreadsheet\Writer\Xls->save('/Applications/X...')
#4 /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/samples/csv_to_xsl.php(56): writeToSpreedshe in /Applications/XAMPP/xamppfiles/htdocs/phpspread/PhpSpreadsheet/src/PhpSpreadsheet/Cell.php on line 577

Failed to parse date/time format

I get the following exception when trying to parse a ODS file:

Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (1900-01-08T00:57:35.9999999999) at position 0 (1): The timezone could not be found in the database in /bla/foo/third-party/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods.php:533

The file contains personal data so I cannot attach it.

Add row with data

Is there a way to add a row with data like this?
$spreadsheet->setActiveSheetIndex(0)->addRow(["Hello","Welt"])

i found only the example to set cells

$spreadsheet->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!');

Unknown constant used

Unknown constant used as default parameter in \PhpOffice\PhpSpreadsheet\Settings::setCacheStorageMethod
public static function setCacheStorageMethod($method = CachedObjectStorageFactory::cache_in_memory, $arguments = [])

add chart color support

Add a way to set data series color (and other attributes) for various chart types (at minimum bar and line).

I am willing to pay for this addition.

HYPERLINK function not working correctly when you try to link a cell to another spreadsheet

When you set the content of a cell to =HYPERLINK("#anotherspreadshet!A1","link") the class throws the next Fatal error:


Uncaught exception 'PhpOffice\PhpSpreadsheet\Calculation\Exception' with message 'anotherspreadshet!A1 -> Formula Error: An unexpected error occured' in \src\PhpSpreadsheet\Cell.php:280
Stack trace:
#0 src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1080): PhpOffice\PhpSpreadsheet\Cell->&gt;getCalculatedValue()
#1 src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1027): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCell(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet), 'A1', Array, Array)
#2 src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(80): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeSheetData(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet), Array)
#3 srcl\PhpSpreadsheet\W src\Cell.php on line 280

Get NamedRange Value

Hello,

In Excel I can define a named range for some cell and later get value by range name in formulas. Like "=CAPITAL*QUOTE".
Can we have some similar method in NamedRange class to retrieve value of the range?

Thanks!

Make global usage of use in header of files

As mentioned in PR #75 it is better to use use in header. Then you only need to change that header and not all references in many lines.

A very tiny example:

use \Vendor\Project\Type\Foo;

$fooInstance = new Foo();
[...]
$someValue = Foo::getSomeValueFromBar($bar);

Now just imagine the world without use, you have to update many lines. With use, you only need to touch the header of the file, nothing more.

Switch unit tests data format to PHP

So far we used a custom format to store data for unit tests. Mark came up with idea to get rid of it to simplify writing and parsing. Plain PHP files seems to be the best choice, allowing for potentially complex structure, exact type usage and comments.

Get a resource from Writers for PSR-7 integration

Hi there,

I want to suggest a feature for the Writers. Not easy to implement if I trust the current codebase, but pretty helpful for many integrations.

Modern PSR-7 frameworks needs to work with, well, PSR-7 Response objects. These objects use Stream objects that rely on resources to fetch data.

In the current version of PhpSpreadsheet, it's only possible to write on a file or php://output / php://stdout. It's quite tricky to get a resource this way, and writing to a temporary file could not be a viable option on many application architecture.

Adding an abstract getResource method to BaseWriters would be a great improvement for PSR-7 frameworks integration.

Cannot load xltx template with conditional formatting or table used anywhere

Hi to all!

Im trying to open existing template for avoid building workbook from scratch.
It's impossible to load the template if conditional style or table was used. Source templates attached templates.zip

<?php
/*
 * @file PhpSpreadsheet-master/samples/test.php
 */

require __DIR__ . '/Header.php';

// $template = __DIR__ . '/../template_no_issues.xltx';
// $template = __DIR__ . '/../template_bug_table.xltx';
$template = __DIR__ . '/../template_bug_conditional_formatting.xltx';
$output = __DIR__ . '/../workbook_' . date('d_m_Y_H_i_s') . '.xlsx';

// Create temporary file that will be read
$helper->log('Create new Spreadsheet object from ' . $template . ' template');
$callStartTime = microtime(true);
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($template);
$helper->logRead('Excel2007', $template, $callStartTime);

// Export to Excel2007 (.xlsx)
$helper->log('Write to Excel format');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007');
$callStartTime = microtime(true);
$writer->save($output);
$helper->logWrite($writer, $output, $callStartTime);

Error log:

[04-Oct-2016 12:08:37 UTC] PHP Catchable fatal error:  Argument 2 passed to PhpOffice\PhpSpreadsheet\Reader\Excel2007::readStyle() must be an instance of stdClass, instance of SimpleXMLElement given, called in /home/vagrant/vhosts/test/PhpSpreadsheet-master/src/PhpSpreadsheet/Reader/Excel2007.php on line 648 and defined in /home/vagrant/vhosts/test/PhpSpreadsheet-master/src/PhpSpreadsheet/Reader/Excel2007.php on line 1898
[04-Oct-2016 12:08:37 UTC] PHP Stack trace:
[04-Oct-2016 12:08:37 UTC] PHP   1. {main}() /home/vagrant/vhosts/test/PhpSpreadsheet-master/samples/test.php:0
[04-Oct-2016 12:08:37 UTC] PHP   2. PhpOffice\PhpSpreadsheet\IOFactory::load() /home/vagrant/vhosts/test/PhpSpreadsheet-master/samples/test.php:26
[04-Oct-2016 12:08:37 UTC] PHP   3. PhpOffice\PhpSpreadsheet\Reader\Excel2007->load() /home/vagrant/vhosts/test/PhpSpreadsheet-master/src/PhpSpreadsheet/IOFactory.php:175
[04-Oct-2016 12:08:37 UTC] PHP   4. PhpOffice\PhpSpreadsheet\Reader\Excel2007::readStyle() /home/vagrant/vhosts/test/PhpSpreadsheet-master/src/PhpSpreadsheet/Reader/Excel2007.php:648

Environment: PHP 5.6.24 on Centos

Any plans to support apples numbers format?

I don't know how much people are using actually Numbers from Apples iWork Suite but are there any plans to support this filetype too?

I know also that the Numbers file is not documented and it would be needed to reverse engineer this format application/x-iwork-numbers-sffnumbers

HTML export with wrong styles

Hi,
I use several days PhpSpreadsheet for a project. It works great, I'm excited! But I have a problem now with HTML excport. I first set the default border with an array to all cells:

        $this->stdStyle = [
            'borders' => [
                'allborders' => [
                    'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                    'color' => [
                        'argb' => 'FFC0C0C0'
                    ],
                ],
            ],
        ];

Then I use following style array for the first two rows on the right side:

        $this->blackBorderStyle = [
            'borders' => [
                'outline' => [
                    'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM,
                    'color' => [
                        'argb' => \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLACK
                    ],
                ],
            ],
        ];

But I see the left Border of the third row has the black border. It should be grey. And the right border disappears. This happens just in HTML export. The borders in exported Xlsx File are correct.

Can somebody correct this? Thanks in advance!

Bobo
html_style_error

wrong comment in Reader\IReader

comment for load() method in the IReader interface should specify @return Spreadsheet instead of @return PhpSpreadsheet (which doesn't exist)

bug : Infinite loop in OLERead

Trying to use OLERead::read() for build a xls file validator, I found an infinite loop.

It happen in lines 152 to 159 :

while ($sbdBlock != -2) {
    $pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE;

    $this->smallBlockChain .= substr($this->data, $pos, 4 * $bbs);
    $pos += 4 * $bbs;

    $sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock * 4);
}

$sbdBloc takes that values : (0, 1, 2, 3, 4, 5, 6, 7, 8, 254) and reset to 0 (never become -2)
NOTE : (254 * 4) > strlen($this->bigBlockChain) causing problem in self::getInt4d()

You can try this with the attached file.
corrupted_excel_file.xls.zip

Mpdf v7 fatal error

I try to generate a PDF from your samples, but get an Fatal error:

Fatal error: Uncaught TypeError: Argument 1 passed to PhpOffice\PhpSpreadsheet\Writer\PDF\MPDF::__construct() must be an instance of PhpOffice\PhpSpreadsheet\Spreadsheet, none given, called in <mypath>\vendor\PhpSpreadsheet\src\PhpSpreadsheet\Writer\PDF\MPDF.php on line 92 and defined in <mypath>\vendor\PhpSpreadsheet\src\PhpSpreadsheet\Writer\PDF\MPDF.php on line 42
  • PhpSpreadsheet develop branch (commit 3cc80bd)
  • Mpdf v 7.0.0
  • PHP v 7.0.10RC1
  • OS: Windows 8.1

When I load Mpdf separatly, and use namespaces it works.
I changed the line src\PhpSpreadsheet\Writer\PDF\MPDF.php:92 from

$pdf = new self();

to

$pdf = new \Mpdf\Mpdf();

Official, Lightweight Docker Image

It would be fantastic if there could be an official, lightweight (based off Alpine preferably) Docker image for PHPOffice and it's components (such as PHPSpreadsheet)

Lots of people are hesitant to install and maintain apps (Especially with PHP and I intend no offence) directly onto servers and having the ability to quickly spin up PHPOffice as a docker image on one or many servers not only greatly simplifies the install and deployment process, but can add a layer of security when coupled with SELinux and proper cgroup isolation. (Note: I am not saying that Docker itself adds security).

I found a popular PHP+FPM+Nginx base image that help you out: https://hub.docker.com/r/richarvey/nginx-php-fpm/ it should result in a nice lightweight image, ready to have the PHPOffice apps added on top which should be trivial for someone that knows the product set (not I).

Remove all deprecated things

Deprecated things should either be dropped entirely and their replacement be documented, or the @deprecated mentions should be dropped. As noted in PHPOffice/PHPExcel#1029 it's unfortunately not always clear why it was deprecated in the first place.

php autoload without Autoloader.php

set_include_path('classes/');
spl_autoload_extensions('.php');
spl_autoload_register();

This requires the use of the letters in the file names in lowercase.

Handling issues/PRs in PHPExcel and which branch is stable?

There are currently over 440 issues and over 130 PRs which seem to be not handled due to that PHPExcel is obsolete (in favour of PHPSpreadsheet). To avoid that people keep running to the old project and report there, issues and PRs should be closed and noted that development does now happen here (PHPSpreadsheet).

I also wonder that is the latest stable branch over there? For example 1.8 has one commit more than develop which is normally not the case (as developer branches are mostly ahead of release branches).

Switch Date Handling Routines to use DateTime internally

Switch Date Handling Routines to use DateTime internally (to avoid use of unix Timestamp and ensure full range of Excel DateTimes on 32-bit systems), and use DateTimeInterface for typehinting so that DateTime or DateTime immutable can both be used

Fails to calculate INDEX() function

Sample formula:
=INDEX({"First","Second","Third","Fourth","Fifth","Sixth","Seventh"}, 4)

Errors thrown:
Undefined offset: 3 in /var/www/html/hoosh/excel_v2/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php on line 603
Undefined index: in /var/www/html/hoosh/excel_v2/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php on line 610

Bug fix in Border.php

Dear,

To allow setting of border properties, I think a bug fix has to be performed:

diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php
index dc557f7..d320de0 100644
--- a/src/PhpSpreadsheet/Style/Border.php
+++ b/src/PhpSpreadsheet/Style/Border.php
@@ -150,7 +150,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable
             case 'right':
             case 'top':
             case 'vertical':
-                $key = strtolower('vertical');
+                $key = strtolower($this->parentPropertyName);
                 break;
         }

0001-MyRoFix-Border.php-getStyleArray-bug-fix-allows-a-bo.patch.zip

XLSM support

Hi there,

I found PhpExcel a great library and wanted to give a go to PhpSpreadsheet to import XLSM files into my website but I am facing an issue.

When loading an XLSM file using IOFactory::load($filename), the Excel2007 reader is created (as expected) but when the readStyle() method is then called, the second argument is expected to be an stdClass but a SimpleXMLElement is given, thus throwing an exception.

As a side note, is PhpSpreadsheet ready for production yet or would you recommend I'd rather stick to PhpExcel?

Cheers.

Does not work drawing

Image do not appear in spreadsheet after this code but in PhpExcel this works.

        $signaturePath = \Yii::$app->basePath.'/storage/for_documents/sign.png';
        $objDrawing = new Drawing();    //create object for Worksheet drawing
        $objDrawing->setName('Sign');
        $objDrawing->setDescription('Sign');
        $objDrawing->setPath($signaturePath);
        $objDrawing->setWidth(60);
        $objDrawing->setWorksheet($this->sheet);
        
        $objWriter = IOFactory::createWriter($saleDocumentInExcel, "Excel5");

Excel doesn't recognize the password

Hello guys, I'm using PhpSpreadsheet in order to generate a protected Excel file.
But after using the sample "41 - Password". Excel doesn't recognize the "secret" password used in the sample.

Any ideas?
Thank you

Missing getParent/getWorksheet() in Row class

In constructor of Row class Worksheet is given as parameter and set in object but not exposed to outside. Currently I may need a simple getter to get the worksheet's title.

Or is there another way of getting a worksheet instance from a row instance? What I want to do is this:

// Create cache key
$cacheKey = sprintf(
    'column:%s:%s:%d:%s',
    pathinfo($fqfn, PATHINFO_BASENAME),
    $rowInstance->getWorksheet()->getTitle(),
    $rowInstance->getRowIndex(),
    $value
);

Incorrect output for match function

Formula sample: =MATCH(MAX({0,0,0,1,0,0,0,2,0,0,0,0,0,0,1,0,0}),{0,0,0,1,0,0,0,2,0,0,0,0,0,0,1,0,0})

Code sample:

$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$spreadsheet->getActiveSheet()->setCellValue(
    'A1',
    '=MATCH(MAX({0,0,0,1,0,0,0,2,0,0,0,0,0,0,1,0,0}),{0,0,0,1,0,0,0,2,0,0,0,0,0,0,1,0,0})'
);
echo $spreadsheet->getActiveSheet()->getCell('A1')->getCalculatedValue();

This results to 4. The output i tested in excel, libreoffice calc and google sheets is 17.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.