Closed lokomass closed 3 months ago
Using a slight variation on your code (among other things a much smaller merge range A2:B5), I see bottom and right borders, but not left nor top. PhpSpreadsheet establishes the border attributes for merged cells in Html (and therefore Pdf) using the css !important
attribute. Mpdf does not appear to support that attribute, which is the reason for your problem. If you were to generate your output as Html, or as Dompdf, you would see the border.
Although this is an Mpdf problem, code similar to the following within your application will work around that problem and get the desired result almost all the time:
function mpdfborders(string $html): string
{
return preg_replace('/border-(top|bottom|right|left):none #000000;/', '', $html) ?? $html;
}
...
$writer = new Mpdf($spreadsheet);
$callback = 'mpdfborders';
$writer->setEditHtmlCallback($callback);
$writer->save($filename);
This is:
What is the expected behavior?
An outline border around merged cells
What is the current behavior?
NO border all around
What are the steps to reproduce?
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:
I can't set a border to merged cells, thanks for help