Skip to content

Cannot set border color for cells range #428

@vstokarev

Description

@vstokarev

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions