phpspreadsheet:在单元格中放置/显示多个空间(空间/凹痕)

发布于 2025-01-30 07:27:36 字数 788 浏览 4 评论 0原文

我正在使用\ phpoffice \ phpspreadsheet \ Reader \ html()读取HTML表以将其保存到XLSX电子表格中。我需要在某些行上进行缩进,例如应该这样看:

Cost of Sales
  Stock
  Courier Fees

在HTML表中,使用& amp; amp; amp; amp; amp; nbsp; nbsp; 很容易了进入Excel细胞的空间。我已经尝试了“  nbsp; nbsp;'' (多个空间)和< td style ='padding-Left:10px;'> ,甚至< td style ='Margin-Left:10px;'> 以防万一,一切都无济于事。我在Google上找不到任何东西可以提供帮助,并希望有任何建议。

以防万一,我将包括如何阅读/编写存储在$ Incomestatement中的HTML表:

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Html();
$spreadsheet = $reader->loadFromString($incomeStatement);
// [headers]
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$spreadsheet->save('php://output');

I'm using \PhpOffice\PhpSpreadsheet\Reader\Html() to read an HTML table to save into an XLSX spreadsheet. I need indentation on some rows, for example it should appear like this:

Cost of Sales
  Stock
  Courier Fees

In the HTML table it's easy using    , but this doesn't take those multiple spaces into the Excel cells. I've tried "   " (multiple spaces) and <td style='padding-left:10px;'> and even <td style='margin-left:10px;'> just in case, all to no avail. I can't find anything on Google to assist and would appreciate any advice.

Just in case, I'll include how I'm reading/writing the HTML table stored in $incomeStatement:

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Html();
$spreadsheet = $reader->loadFromString($incomeStatement);
// [headers]
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$spreadsheet->save('php://output');

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很酷又爱笑 2025-02-06 07:27:36

使用HTML TAG span之后的示例类似于

<span> </span> <span> </span> <span> </span> <span> </span> 

该示例的示例之类的空间,将成为4个空格

use combination with html tag span followed by space like sample below

<span> </span> <span> </span> <span> </span> <span> </span> 

this example will make 4 spaces

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文