Excel reports via VStudio 2005 - create groups?

Susana

New member
Joined
Jun 4, 2009
Messages
3
Programming Experience
Beginner
Hi,
I have a problem while creating Excel reports using VS 2005. I am not able to create groups so the table can show colapsed groups, I mean, several rows contained in another one. Here I leave you the code I am trying to make it work. I will really appreciate any help you can provide


m_Excel.ActiveWindow.DisplayOutline = True

m_Excel.Range("A7:A16").OutlineLevel = 3
m_Excel.Range("A29:A40").OutlineLevel = 4
m_Excel.Range("A42:A50").OutlineLevel = 4
m_Excel.Range("A52:A57").OutlineLevel = 4
m_Excel.Range("A59:A60").OutlineLevel = 4
m_Excel.Range("A62:A70").OutlineLevel = 4
m_Excel.Range("A72:A77").OutlineLevel = 4
m_Excel.Range("A79:A80").OutlineLevel = 4
m_Excel.Range("A82:A85").OutlineLevel = 4
m_Excel.Range("A87:A88").OutlineLevel = 4

objHojaExcel.Range("A7:A88").group()
objHojaExcel.Outline.ShowLevels(4,0)

Kind regards.
Muchas gracia sy un saludo!!
 
Hi again, I'd really appreciate if you could help me, as I am really stuck here, nobody could solve this problems in other forums, it's a challenge.

Group function definition:

Function Group(Optional ByVal Start As Object = Nothing, Optional ByVal End As Object = Nothing, Optional ByVal By As Object = Nothing, Optional ByVal Periods As Object = Nothing) As Object
Member of: Microsoft.Office.Interop.Excel.Range
 
Not really sure if this is what you are looking for but here's what I use. Only ran it on a few simple test but seemed to work ok.

VB.NET:
Public Sub GroupRows(ByVal firstRow As Integer, ByVal lastRow As Integer)

    'select the rows you wish to group
    xlsRange = xlsApp.Range(firstRow.ToString & ":" & lastRow.ToString)
    xlsRange.Rows.Select()

    'group the rows
    xlsRange.Rows.Group()

End Sub
 
Back
Top