Win32 OLE (perl) - 将 table 列宽调整为文本

Win32 OLE (perl) - resize table column width to text

我有一个 Perl 脚本,它使用 Win32::OLE.
将带有一些文本的行添加到 Word 文档中的现有 table 现在,我想让它也调整 table 列的大小以匹配文本大小(就像双击两列之间的垂直线一样) 我知道如何将列设置为特定宽度,但我似乎找不到 API 来调整列的大小以匹配文本大小。

谁能告诉我要找什么?

作为参考,这是我的脚本中的代码片段:

my $tbl = $document->Tables(1);
my $row = $tbl->Rows->Add();
$row->Cells(1)->Range()->InsertAfter($timestamp);
$row->Cells(2)->Range()->InsertAfter($comment);
$row->Cells(3)->Range()->InsertAfter($username);
# TODO: resize columns to match the content

您是否尝试过 Cells.AutoFit() 方法?例如Columns.AutoFit

不过似乎只支持 Excel 2010 及更新版本。

https://msdn.microsoft.com/en-us/library/office/ff837476.aspx