gpt4 book ai didi

excel - Excel中如何获取行高?

转载 作者:行者123 更新时间:2023-12-02 19:37:28 26 4
gpt4 key购买 nike

有没有办法在openxml中获取excel行的行高?就我而言,我使用 openxml 2.0 从 .net 数据表生成 Excel 表。对于每个数据表行,我在 Excel 中定义新行

  row = new Row() { RowIndex = rowIndex };

之后我将单元格附加到行

 row.InsertBefore(newCell, refCell);

完成生成 Excel 表格后,我想让每一行的高度增加。但使用时总是为null

    Row row = ExcelHelper.GetRow(sheetData, Convert.ToUInt32(13));
DoubleValue a = row.Height;

请帮帮我!谢谢!

最佳答案

当 XML 中的 customHeight 属性设置为 true 时,Microsoft Excel Open XML 格式行仅具有 height 属性,否则行高仅为 DefaultRowHeight .

您应该做的是首先检查是否 row.CustomHeight != null && row.CustomHeight.Value == true 然后您就知道它具有自定义高度和 Height code> 属性不会为空。

在另一种情况下,您可以在 SheetFormatProperties.DefaultRowHeight 中获取默认行高。 .

因此,要将行的高度设置为自定义值,您需要将其 CustomHeight 属性更改为 true,并将 Height 属性更改为自定义行高。

关于excel - Excel中如何获取行高?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34763520/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com