Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Automation - Help Grouping Rows

Status
Not open for further replies.
Mar 9, 2006
93
CA
I am creating an application that gathers information from several databases and then creates an excel report with this information. The problem is that there are thousands of rows and I do not want them all to be visible at first. I know how to create the excel report through c# but I am not sure of to Group some rows together so that they are hidden unless the user expands these rows. Does anyone know how to do this?
Thanks
Matt
 
I imagine there is a way to select and hide some rows, but I have never had to do it.

If you could identify the rows you need to hide, then it becomes simple:

Code:
     // VBA, should be easy conversion
    Rows("3:14").Select
    Selection.EntireRow.Hidden = True

HOpe this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Hey, I just had to hide some columns for a report I was working on. I had to first select a range, then hide the entire column for selected range. I imagine it works the same for rows (but I don't want to mess with my report)

Code:
wRange = xlSheet.get_Range(xlSheet.Cells[1, mDT.Columns.Count + 1], xlSheet.Cells[1, 60]);
wRange.EntireColumn.Hidden = true;

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Thanks for you help. I managed to figure it out for anyone who is interested. The following code will group the rows A4-A6 so they can be expanded anytime. Also this code will initially have the rows hidden.

Excel.Range rang = worksheet.Columns.get_Range("A4", "A6");
rang.Rows.Group(Type.Missing, Type.Missing , Type.Missing, Type.Missing);
rang.Rows.Hidden = true;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top