PHPSpreadsheet setAutoSize 函数未按预期工作

发布于 2025-01-10 08:21:58 字数 789 浏览 8 评论 0原文

我正在使用 PHPSpreadsheet 并且我正在执行以下操作来自动调整相关列的

foreach (range('A', 'K') as $col) {
    $productsSheet->getColumnDimension($col)->setAutoSize(true);
}

大小 :然而,添加了额外的填充。

以下是我使用 setAutoSize 函数使用自动调整大小时的情况: PHPSpreadsheet

这是在 Excel 中执行自动调整大小后的结果:

Excel

对于较宽的单元格,它变得更加突出,从而使导出的范围比需要的范围宽得多。

有什么办法可以解决这个问题吗?手动设置每列的宽度对我们来说是不可接受的,因为内容变化很大。

I am using PHPSpreadsheet and I'm doing the following to autosize the relevant columns:

foreach (range('A', 'K') as $col) {
    $productsSheet->getColumnDimension($col)->setAutoSize(true);
}

The issue is, however, that extra padding is added.

The following is when I use autosize with using the setAutoSize function:
PHPSpreadsheet

And here it is after doing the autosize in Excel:

Excel

It becomes even more prominent for wider cells thus making the export far wider than it needs to be.

Is there anything that can be done about this, manually setting the width of each column is not acceptable for us as the content is highly variable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文