我们如何根据 xlsx 中单元格的内容给出高度?

发布于 2025-01-15 05:38:51 字数 511 浏览 1 评论 0原文

我正在尝试通过 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 技术交流群。

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

发布评论

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

评论(1

锦爱 2025-01-22 05:38:51

如果您从 row 的 XML 中完全删除 htx14ac:dyDescent 属性,则高度将根据内容自动计算只要该行中没有任何合并单元格即可。

因此,

   <row r="26" spans="1:26">
       <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>

只要该行中没有任何合并单元格,并且 s="41" 指向 wrapText 设置为 true 的单元格样式,就应该看起来像您想要的那样。

为什么要删除显式的 ht 集应该是不言自明的。如果不存在,将进行隐式高度计算。

为什么需要额外删除 x14ac:dyDescent2.5.3 dyDescent 的文档 告诉它:

dyDescent 属性有一个副作用;它设置了
即使 customHeight 属性显式设置为 false,customHeight 属性也设置为 true。

因此,如果设置x14ac:dyDescent,则不会进行隐式高度计算。

If you would completely remove the ht and the x14ac:dyDescent attribute from the row's XML, then the height will be auto calculated by content as long as there are not any merged cells in that row.

So

   <row r="26" spans="1:26">
       <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>

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 where wrapText 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:

The dyDescent attribute has a side effect; it sets the
customHeight attribute to true even if the customHeight attribute is explicitly set to false.

So if set x14ac:dyDescent, then no implicit height calculation will be done.

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