PhpSpreadsheet 在 sheet 标签标题旁边放了一个数字
PhpSpreadsheet is putting a number beside sheet label title
这是我的代码:-
$facilities = Facility::where('area_id','!=',1)->where('area_id','!=',4)->get();
$spreadsheet = new Spreadsheet();
foreach($facilities as $i => $facility){
$spreadsheet->setActiveSheetIndex($i);
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('test');
if(($i+1) !== count($facilities)){
$spreadsheet->createSheet();
}
}
$spreadsheet->setActiveSheetIndex(0);
$writer = new Xlsx($spreadsheet);
$writer->save(base_path().'/tracking-file/test.xlsx');
我只是用 ('test') 为每个 sheet 加上标题的问题,输出显示标题旁边的数字:-
如何从标签标题中删除这些数字?
根据 the docs on adding a new Worksheet:
A new worksheet created using this method will be called Worksheet<n>
where <n>
is the lowest number possible to guarantee that the title is
unique.
可以在 Worksheet::setTitle
's source code 中找到相同的行为。
这是我的代码:-
$facilities = Facility::where('area_id','!=',1)->where('area_id','!=',4)->get();
$spreadsheet = new Spreadsheet();
foreach($facilities as $i => $facility){
$spreadsheet->setActiveSheetIndex($i);
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('test');
if(($i+1) !== count($facilities)){
$spreadsheet->createSheet();
}
}
$spreadsheet->setActiveSheetIndex(0);
$writer = new Xlsx($spreadsheet);
$writer->save(base_path().'/tracking-file/test.xlsx');
我只是用 ('test') 为每个 sheet 加上标题的问题,输出显示标题旁边的数字:-
如何从标签标题中删除这些数字?
根据 the docs on adding a new Worksheet:
A new worksheet created using this method will be called
Worksheet<n>
where<n>
is the lowest number possible to guarantee that the title is unique.
可以在 Worksheet::setTitle
's source code 中找到相同的行为。