Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel with protection, black cells after edit #1353

Closed
bbinotto opened this issue Feb 7, 2020 · 4 comments
Closed

Excel with protection, black cells after edit #1353

bbinotto opened this issue Feb 7, 2020 · 4 comments

Comments

@bbinotto
Copy link
Contributor

bbinotto commented Feb 7, 2020

This is:

- [X ] a bug report
- [ ] a feature request
- [x ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Open TestCaseAnonym.xlsx and write into unprotected cell should not change style of other cells.

What is the current behavior?

Open
TestCaseAnonym.xlsx
, write into unprotected cell, save to TestCaseOutput.xlsx.
Lots of cells (probalbly all protecte?) are now unreadable because they have a black background color.

What are the steps to reproduce?

composer install
php -f TestCase.php
View TestCaseOutput.xlsx.

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php
include_once "vendor/autoload.php";

use PhpOffice\PhpSpreadsheet\IOFactory;
class TestCase
{
    /**
     * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
     * @throws \PhpOffice\PhpSpreadsheet\Exception
     */
    public static function Exec(){
            $objReader = IOFactory::createReader("Xlsx");
            $excel = $objReader->load("TestCaseAnonym.xlsx");
            $excel->setActiveSheetIndex(1);
            $activeSheet = $excel->getActiveSheet();
            $activeSheet->SetCellValue("J21", utf8_encode("2"));
            $objWriter = IOFactory::createWriter($excel,"Xlsx");
            $objWriter->save("TestCaseOutput.xlsx");
    }
}

TestCase::Exec();

Which versions of PhpSpreadsheet and PHP are affected?

1.10.1
I have the same issue with the old PhpExcel.
php 7.2

@bbinotto
Copy link
Contributor Author

bbinotto commented Feb 7, 2020

Complete example
MinimalExcel.zip

@bbinotto
Copy link
Contributor Author

bbinotto commented Feb 8, 2020

I found that Xlsx.php@1624 causes this:
//$docStyle->getFill()->getStartColor()->setARGB('FF000000');

Anyone has an idea what the side effects are if we just remove this?

@stale
Copy link

stale bot commented Apr 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Apr 8, 2020
@plagiatmakc
Copy link

plagiatmakc commented Apr 14, 2020

I found that Xlsx.php@1624 causes this:
//$docStyle->getFill()->getStartColor()->setARGB('FF000000');

Anyone has an idea what the side effects are if we just remove this?

Xlsx.php@1624
I think that this is better way:
$docStyle->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE);
instead

//$docStyle->getFill()->getStartColor()->setARGB('FF000000');

because this way the background becomes transparent, and in your case it’s just white.

Sorry for my english....

@stale stale bot removed the stale label Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants