5

I am using range.group method from the Microsoft.Office.Interop.Excel.dll and it works to group up the columns or rows as the outline level in the Excel document; but there comes the question of how to set the "+"symbol at the left side, but not it's default position at the right side according to the last columns or rows.

What method is used for controlling the direction and how to use this method. It would be best if that's an example,.

ekad
  • 14,436
  • 26
  • 44
  • 46
singa
  • 51
  • 1
  • 2
  • why do u want to Keep "+" symbol on the Left side ? – Sangram Nandkhile Apr 01 '11 at 06:50
  • Sorry,but i did not understand your question and actually what u want to do ? IF u can edit it write in better way that would be very helpful. – Sangram Nandkhile Apr 01 '11 at 06:58
  • Sorry,my english is not good.I want to make the "+" symbol of outline level at the left side instead of it's default setting at the right side. – singa Apr 01 '11 at 07:02
  • may be this codes will help to understand. m_objSheet.get_Range(j + ":" + Convert.ToInt32(rg.Cells.Row-1), Missing.Value).Rows.Group(Type.Missing, Type.Missing, Type.Missing, Type.Missing); m_objSheet.Outline.ShowLevels(1,1); – singa Apr 01 '11 at 07:07
  • are u refering symbo **+** which is used to concatenate strings (j + ":" + Convert.ToInt32(rg.Cells.Row-1), ? – Sangram Nandkhile Apr 01 '11 at 07:48
  • @singa: Show us an example, so we don't have to guess what you're trying to do. @Sangram: Are "u" writing from "ur" 12 year old mobile phone?! – Jean-François Corbett Apr 01 '11 at 09:19
  • range = m_objSheet.get_Range("A1:"+maxcolcount+1,Missing.Value); foreach(Microsoft.Office.Interop.Excel.Range cg in range) { if (cg.Value2 != null) { if (cg.Value2.ToString().EndsWith("-非优质店")) { m_objSheet.get_Range(transformvalue(cg.Column - 1) + ":" + transformvalue(cg.Column), Missing.Value).Columns.Group(Type.Missing, Type.Missing, Type.Missing, Type.Missing); } } } – singa Apr 01 '11 at 10:28
  • this was part of my codes. if (cg.Value2.ToString().EndsWith("-非优质店")) { m_objSheet.get_Range(transformvalue(cg.Column - 1) + ":" + transformvalue(cg.Column), Missing.Value).Columns.Group(Type.Missing, Type.Missing, Type.Missing, Type.Missing); this statement will outline the columns that match my codition in the excel sheet.and we open the excel file,we can see the "+"symbol at the top of the sheet.the symbol form at the last column which match my codition,i wanna it form at the first column which matched. – singa Apr 01 '11 at 10:33

2 Answers2

5

In excel: Data/Group and Outline/Settings...

In code:

range.Group(oMissing, oMissing, oMissing, oMissing);

//for rows
worksheet.Outline.SummaryRow = Excel.XlSummaryRow.xlSummaryAbove;

//for columns
worksheet.Outline.SummaryColumn = Excel.XlSummaryColumn.xlSummaryOnLeft;
Stijn Bollen
  • 386
  • 4
  • 9
2

To apply it on the left without using VBA:

In Excel: Data-> Outline. Click on the arrow on the bottom right corner of the ribbon (The arrow is pointing down right.)

It will open the Outline Settings.

Untick "Summary column on the right on the right of detail." Click Apply Styles.

Gerhard Powell
  • 5,965
  • 5
  • 48
  • 59