对于我的C#应用程序,用户将输入注释行,这些注释最终将导出到Excel工作表。这些备注将放置在合并的列单元格(I到L列)中。我面临的问题是,当Excel工作表打开时,我总是看到空白,因为内容占用了太多的垂直空间。仅在手动调整高度后,我才能查看单元格中的备注。
我已经尝试过以下操作:aRange.EntireColumn.AutoFit();和worksheet.Columns.AutoFit();和worksheet.Rows.AutoFit();
Excel.Workbook myExcelWorkbook;
Excel.Application xlsxApp = new Excel.Application();
Excel.Worksheet xlsht = new Excel.Worksheet();
File.Copy(AppDomain.CurrentDomain.BaseDirectory + @"checklist.xlsx", AppDomain.CurrentDomain.BaseDirectory + @"checklist_duplicate.xlsx", true);
string path = AppDomain.CurrentDomain.BaseDirectory + @"checklist_duplicate.xlsx;
xlsht = xlsxApp.Application.Workbooks.Open(path).Worksheets["Acceptance"];
// open the existing excel file //
myExcelWorkbook = (Excel.Workbook)(xlsxApp.Workbooks._Open(path, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing));
xlsht.Cells[13, "I"] = Savestate.one_one_one_grouping;/*Adding remarks into the merged column cells*/
如何自动调整这些合并列的高度,以便可以看到这些注释?