Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I am working on a C# application that requires me to enter multi-line data into an Excel 2003 spreadsheet. I am wondering how to automatically resize the row height of merged cells to accomodate all of this text. I attempted to use a dummy cell with the same column width as the merged cells to discern the row height, but this is not working. Below is a snippet of the code that I am using... // dummy cell location string cell = "AA19"; string tempRowHeight = ""; // object for storing original dummy cell height // Create a non-merged dummy cell so we can determine the necessary height of the row Excel.Range dummyCell = (Excel.Range)worksheet.get_Range(cell, cell); // Get the original row height so that we can reset the dummy cell when we are finished tempRowHeight = dummyCell.RowHeight.ToString(); // Set the dummyCell column width to the width of the merged range dummyCell.ColumnWidth = columnWidth; dummyCell.WrapText = true; // force the cell to resize dummyCell.Value2 = locText; // get the rowHeight of the resized cell string rowHeight = dummyCell.RowHeight.ToString(); // remove the text from the dummy cell before continuing dummyCell.Value2 = ""; dummyCell.RowHeight = tempRowHeight; // release the com objects System.Runtime.InteropServices.Marshal.FinalReleas eComObject(dummyCell); dummyCell = null; return rowHeight I then use the calculated rowHeight to set the rowHeight of the merged area. Has anyone else attempted a solution like this with any success? Any help would be much appreciated! Katherine |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Merged cells won't Autofit row height | Excel Discussion (Misc queries) | |||
Automatically Adjusting Row Height in Merged Cells | Excel Discussion (Misc queries) | |||
row height increase automatically to fit contents of merged cells | Excel Discussion (Misc queries) | |||
Row height and Merged Cells | Excel Programming | |||
Row Height for merged cells | Excel Programming |