Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Microsoft.Office.Interop.Excel 将数据写入 excel 单元格。单元格具有一定的初始高度,我设置了“合并单元格 = true”和“换行文本 = true”。
当单元格内容较大时,单元格高度不会增加。我尝试了以下两种方法:
_range.entrirerow.autofit() _range.columns.autofit()
这对我不起作用,请提出一些解决方案。
试试 _range.Rows.Autofit();
请注意:COM 对象不会以双句点释放。它创建了您无法访问的临时变量。
所以宁愿使用:
Range rows = _range.Rows; rows.Autfit(); if (rows != null) { Marshal.FinalReleaseComObject(rows); }