You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a column with multiple comma (, ) separated hyperlink strings. I am trying to change them into actual clickable hyperlinks, but can't find a way to do so. If I try it with the code below, it of course just turns the whole cell into one big hyperlink that leads nowhere (because it's just multiple hyperlinks separated with commas). How could I achieve this?:
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
/** @var Worksheet $sheet */
foreach ($event->sheet->getColumnIterator('J', 'J') as $row) {
foreach ($row->getCellIterator() as $cell) {
if (str_contains($cell->getValue(), '://')) {
$cell->setValue(new Hyperlink($cell->getValue(), 'Read'));
// Upd: Link styling added
$event->sheet->getStyle($cell->getCoordinate())->applyFromArray([
'font' => [
'color' => ['rgb' => '0000FF'],
'underline' => 'single'
]
]);
}
}
}
},
];
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
I have a column with multiple comma (, ) separated hyperlink strings. I am trying to change them into actual clickable hyperlinks, but can't find a way to do so. If I try it with the code below, it of course just turns the whole cell into one big hyperlink that leads nowhere (because it's just multiple hyperlinks separated with commas). How could I achieve this?:
Beta Was this translation helpful? Give feedback.
All reactions