using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace iDiTect.Excel.Demo
{
    public static class GroupHelper
    {
        public static void AddGroup()
        {
            var workbook = new Workbook();
            var worksheet = workbook.Worksheets.Add("AddGroup");

            //Group columns 3-8 as level 1 outline
            worksheet.Columns(3, 8).Group();
            //Group columns 3-7 as level 2 outline
            worksheet.Columns(3, 7).Group();
            //Group columns 4-5 as level 3 outline
            worksheet.Columns(4, 5).Group();

            //Grouped columns are expand default.
            //You can expand target columns by outline level - ExpandColumns(int outlineLevel),
            //or expand all grouped columns - ExpandColumns()
            worksheet.ExpandColumns(2);
            //Collapse target columns by outline level - CollapseColumns(int outlineLevel),
            //or collapse all grouped columns - CollapseColumns()
            worksheet.CollapseColumns(3);


            //Group rows 2-5 as level 1 outline
            worksheet.Rows(2, 5).Group();
            //Group rows 2-4 as level 2 outline
            worksheet.Rows(2, 4).Group();

            //Grouped rows are expand default.
            //You can expand target rows by outline level - ExpandRows(int outlineLevel),
            //or expand all grouped rows - ExpandRows()
            worksheet.ExpandRows(1);
            //Collapse target rows by outline level - CollapseRows(int outlineLevel),
            //or collapse all grouped rows - CollapseRows()
            worksheet.CollapseRows(2);          
            
            workbook.Save("AddGroup.xlsx");
        }
    }
}
