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

Cannot set border color for cells range #428

Closed
vstokarev opened this issue Mar 16, 2018 · 4 comments
Closed

Cannot set border color for cells range #428

vstokarev opened this issue Mar 16, 2018 · 4 comments

Comments

@vstokarev
Copy link

This is a bug report

What is the expected behavior?

I want to select a row in spreadsheet and set color for bottom borders of every cell on the row.

What is the current behavior?

It works, but it sets black color for all the rows except for the last one. And only the last cell border gets the color I want.

What are the steps to reproduce?

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

$spreadsheet->getActiveSheet()
            ->getStyle('A10:H10')
            ->getBorders()
            ->getBottom()
            ->setBorderStyle(Border::BORDER_THIN)
            ->setColor(new Color('FFFF0000'));

$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('file.xlsx');

As far as I remember the same approach worked fine in PHPExcel. Anyway, it actually draws the bottom border, the main question is why this border is black, not red? And only the last cell in a row is red.

Which versions of PhpSpreadsheet and PHP are affected?

PHP 7.2.3
PhpSpreadsheet 1.2.0
Checked resulting file in latest Microsoft Excel versions for Mac and Windows.

@damijanc
Copy link

damijanc commented Apr 9, 2018

I can confirm the issue.

@stale
Copy link

stale bot commented Jun 8, 2018

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 Jun 8, 2018
@damijanc
Copy link

Any updates on this issue?

@carlosmolano
Copy link

carlosmolano commented Sep 30, 2021

Hi..
$styleArray = [ 'borders' => [ 'allBorders' => ['borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,], ]]; $spreadsheet->getActiveSheet()->getStyle($rangeTotal)->applyFromArray($styleArray);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants