最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

laravel - How to remove the column highlighting when using columnFormats? - Stack Overflow

programmeradmin1浏览0评论

I am using columnFormats() to format a column as a date:

public function columnFormats(): array
{
    return [
        'C' => NumberFormat::FORMAT_DATE_DDMMYYYY
    ];
}

But it also highlights the formatted column on the exported excel file whenever it's first opened:

Is it possible to remove this highlighting?

I am using columnFormats() to format a column as a date:

public function columnFormats(): array
{
    return [
        'C' => NumberFormat::FORMAT_DATE_DDMMYYYY
    ];
}

But it also highlights the formatted column on the exported excel file whenever it's first opened:

Is it possible to remove this highlighting?

Share Improve this question edited Nov 19, 2024 at 15:24 pileup asked Nov 19, 2024 at 9:14 pileuppileup 3,3305 gold badges31 silver badges69 bronze badges 3
  • 1 can you try in the end of excel to $spreadsheet->getActiveSheet()->getCell('A1'); – francisco Commented Nov 19, 2024 at 9:42
  • @francisco thank you, do you know where I should put it? I tried the following which did not work: public function registerEvents(): array { return [ AfterSheet::class => function (AfterSheet $event) { $event->sheet->getCell('A1'); }, ]; } – pileup Commented Nov 19, 2024 at 15:58
  • @francisco, I did it, I used: $event->sheet->setSelectedCells('A1'); instead! thank you – pileup Commented Nov 19, 2024 at 16:00
Add a comment  | 

1 Answer 1

Reset to default 0

If anyone ever encounters this in the future, this is how I solved it:

public function registerEvents(): array {
    return [
        AfterSheet::class => function (AfterSheet $event) {                 
            $event->sheet->setSelectedCells('A1');
         },
    ];
}

I select the first cell in the sheet and it removes the highlighting

发布评论

评论列表(0)

  1. 暂无评论