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.
Asked
Active
Viewed 177 times
2 Answers
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);
}
}

Tansukh Rathod
- 90
- 5
-
$sheet Which function is placed in? – Sang Vo Feb 17 '21 at 09:29
-
I have modified answer. Please check. Hope it will help you. – Tansukh Rathod Feb 17 '21 at 09:36
-
it does have a new row, but creates 1 new rows. I want it on a row but in text. Like the dark image above – Sang Vo Feb 17 '21 at 09:47
-
`$data = [ "time" => "2020 \r 1996"]` but not dow line it does not create new rows, it creates 1 new rows – Sang Vo Feb 17 '21 at 09:53
-
Are you using laravel excel package ? or core php ? – Tansukh Rathod Feb 17 '21 at 10:01
-
i use laravel-excel.com – Sang Vo Feb 17 '21 at 10:19
-
Please refer answer. You have to map every row – Tansukh Rathod Feb 17 '21 at 10:28
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;
}
}

Tansukh Rathod
- 90
- 5
-
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