-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Border on merged cells #3557
Comments
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 |
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); |
Fix PHPOffice#3557. Borders around merged cells are not handled correctly for Mpdf. Although a perfectly acceptable workaround is suggested in the issue, it would be better if things just worked without the workaround. Html and Dompdf work with the existing code. As it turns out, Tcpdf does not work, but for a different reason than Mpdf. Mpdf was not working because Mpdf does not honor the `!important` attribute in Css. We can get it working almost perfectly by suppressing `border*:none`; the exception is fairly Byzantine, and I'll be glad to discuss the matter should anyone report a problem with it. At any rate, it's not working now in the exception case, so we won't be any worse off. Tcpdf was not working because the merging of attributes happened only when `useInlineCss` was not being used, but Tcpdf does use it. Merging of border attributes is now added for useInlineCss.
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
The text was updated successfully, but these errors were encountered: