0

enter image description here

In the code how can I give a new line down. I want to have days on a row and have to load every day.

Jin Lee
  • 3,194
  • 12
  • 46
  • 86
Sang Vo
  • 25
  • 5

2 Answers2

0

Click here! for solution.

Set your value, with your tab "\r" or "\r\n" then

$sheet->getStyle('C1')->getAlignment()->setWrapText(true);

OR

use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class InvoicesExport implements WithStyles
{
    public function styles(Worksheet $sheet)
    {
        $sheet->getStyle('B2')->getAlignment()->setWrapText(true);
    }
}
0

Just like...

use Maatwebsite\Excel\Concerns\WithMapping;

class ExampleExport implements WithMapping
{    
    public function map($row): array
    {
        $row = [];
        $dates = explode("", $row->dates);
        if(count($dates)){
            $row = [
                "col1",
                "col2",
                "date",
            ]
            foreach($dates as $d){
                $row[] = [
                    '',
                    '',
                    $d
                ];
            }
        } else {
            $row = [
                "col1",
                "col2",
                "date",
            ]
        }
        return $row;
    }
}
  • I don't think this is the answer I need I just want the same as when editing, press control + enter it will descend in 1 row And this code will create 1 row with date and 1 row with enough col1, col2, date – Sang Vo Feb 17 '21 at 11:24