从PhpSpreadsheet列自动调整大小中删除额外的填充/内边距的方法是通过设置列的宽度为自动调整,并且将填充/内边距设置为零。
以下是具体的步骤:
use PhpOffice\PhpSpreadsheet\IOFactory;
$spreadsheet = IOFactory::load('your_excel_file.xlsx');
$worksheet = $spreadsheet->getActiveSheet();
$worksheet->getColumnDimension('A')->setAutoSize(true);
这里的'A'
是你要调整大小的列的标识符,可以根据你的需求进行修改。
$style = $worksheet->getStyle('A');
$style->getAlignment()->setWrapText(true);
$style->getAlignment()->setIndent(0);
这里的'A'
同样是你要调整大小的列的标识符。
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('your_updated_excel_file.xlsx');
通过以上步骤,你可以从PhpSpreadsheet列自动调整大小中删除额外的填充/内边距。
领取专属 10元无门槛券
手把手带您无忧上云