任何方式来设置Excel工作表中的最小单元格高度?

你好,我的问题是如何设置一个Excel工作表单元格的最小高度? 现在看起来像: Excel工作表

但它应该是这样的: 它应该如何看待 我到目前为止设置单元格高度: excelSheet.Columns[1].ColumnWidth = 16.14; 然后excelSheet.Columns[1].Autofit()但它被覆盖,所以我希望find一种方法来设置excelSheet.Columns[1].Autofit()的最小高度。 然后,我试图谷歌,但没有帮助出现。 对于他们合并的单元格

 // Merge the Cells for the summary Box for (int i = 2; i <= 10; i++) { excelSheet.Range[excelSheet.Cells[startColumn + i, 1], excelSheet.Cells[startColumn + i, 10]].Merge(Missing.Value); } 

然后用excelSheet.get_Range("A" + lineBreakAreaTop, "J" + lineBreakAreaBottom).WrapText = true; Mabey,这跟它有关系。

所以任何帮助或build议将是非常感谢您的时间。 对不起,我的英语。

在Excel中模拟最小高度

为了模拟excel行中的Min Height设置,我编写了下面的简单代码,并在我的excel文件中使用下面的指令:

  1. 打开你的excel文件并在ExcelAlt + F11
  2. 点击打开的窗口中的View Codebutton打开Editor

在这里输入图像说明

  1. Copy-PasteEditor的波纹pipe代码

代码

 Private Sub Worksheet_Change(ByVal Target As Range) 'Cells.Rows.AutoFit For rowCounter = 1 To 500 If Rows(rowCounter & ":" & rowCounter).EntireRow.RowHeight < 15 Then Rows(rowCounter).EntireRow.RowHeight = 15 End If Next End Sub 

在这里输入图像说明

注1:如果你想强制工作表对变更也应用Rows AutoFit function ,那么可以通过从上面代码中的代码行开始处删除' sign '来取消注释。

注2:如果excel文件中的数据行数大于500 ,则将上面代码中的数字增加到适当的值。

  1. EditorCtrl + S进行保存
  2. 回到工作表并更改任何单元格值并离开单元格,现在您应该看到结果;)