我们如何根据 xlsx 中单元格的内容给出高度?
我正在尝试通过 XML 创建一个 Excel 文件,我们如何根据单元格的内容给出高度。这里我手动连续添加了ht=27,是否有其他选项可以根据内容更改高度?所以即使它是 3 行或 10 行,它也会看起来不错
<row r="26" spans="1:26" ht="27" x14ac:dyDescent="0.3">
<c r="B26" s="3"/>
......
......
<c r="I26" s="41" t="inlineStr">
<is><t>long text/short text (dynamic text)</t></is>
</c>
......
......
<c r="Z26" s="3"/>
</row>
任何想法/建议,如何做到这一点或替代选项
I am trying to create an Excel file through XML, How can we give a height based on the content of the cell. Here I manually added ht=27 in a row, is there any other option to change the height based on the content? So it will look nice even if it is 3 lines or 10 lines
<row r="26" spans="1:26" ht="27" x14ac:dyDescent="0.3">
<c r="B26" s="3"/>
......
......
<c r="I26" s="41" t="inlineStr">
<is><t>long text/short text (dynamic text)</t></is>
</c>
......
......
<c r="Z26" s="3"/>
</row>
Any idea/suggestions, how to do that or alternate option
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您从
row
的 XML 中完全删除ht
和x14ac:dyDescent
属性,则高度将根据内容自动计算只要该行中没有任何合并单元格即可。因此,
只要该行中没有任何合并单元格,并且
s="41"
指向wrapText
设置为 true 的单元格样式,就应该看起来像您想要的那样。为什么要删除显式的
ht
集应该是不言自明的。如果不存在,将进行隐式高度计算。为什么需要额外删除
x14ac:dyDescent
? 2.5.3 dyDescent 的文档 告诉它:因此,如果设置
x14ac:dyDescent
,则不会进行隐式高度计算。If you would completely remove the
ht
and thex14ac:dyDescent
attribute from therow
's XML, then the height will be auto calculated by content as long as there are not any merged cells in that row.So
should look as you want as long as there are not any merged cells in that row and
s="41"
points to a cell style wherewrapText
is set true.Why to remove the explicit set of
ht
should be self explanatory. If not present, implicit height calculation will be done.Why additional the remove of
x14ac:dyDescent
is necessary? Documentation of 2.5.3 dyDescent tells it:So if set
x14ac:dyDescent
, then no implicit height calculation will be done.