S
Sudip_inn
Guest
I have taken help from one of SO post for having multi level collapse How to set multi level collapsible outlines using EPPlus
I am trying to learn how to do multi level row & column collapse and My code is working. the only issue is multiple expand and collapse +/- symbol not showing in excel file after generating. please tell me what is missing in my code. here is my code.
var datatable = new DataTable("tblData");
datatable.Columns.AddRange(new[]
{
new DataColumn("Header", typeof (string)),
new DataColumn("Col1", typeof (int)),
new DataColumn("Col2", typeof (int)),
new DataColumn("Col3", typeof (object))
});
for (var i = 0; i < 10; i++)
{
var row = datatable.NewRow();
row[0] = String.Format("Header {0}", i);
row[1] = i;
row[2] = i * 10;
row[3] = Path.GetRandomFileName();
datatable.Rows.Add(row);
}
//Create a test file
var fi = new FileInfo(@"d:\Row_Grouping_Test2.xlsx");
if (fi.Exists)
fi.Delete();
using (var pck = new ExcelPackage(fi))
{
var worksheet = pck.Workbook.Worksheets.Add("Sheet1");
worksheet.Cells.LoadFromDataTable(datatable, true);
worksheet.Cells["B12"].Formula = "SUM(B2:B11)";
worksheet.Cells["C12"].Formula = "SUM(C2:C11)";
//Row Group 1
for (var i = 2; i <= 6; i++)
{
worksheet.Row(i).OutlineLevel = 1;
//worksheet.Row(i).Collapsed = true;
}
//Row Group 2
for (var i = 7; i <= 11; i++)
{
worksheet.Row(i).OutlineLevel = 1;
//worksheet.Row(i).Collapsed = true;
}
//Column Group
for (var i = 2; i <= 4; i++)
{
worksheet.Column(i).OutlineLevel = 1;
//worksheet.Column(i).Collapsed = true;
}
pck.Save();
}
There is two row group 1 and 2. for 1 group expand collapse icon is showing but for group 2 no expand collapse icon showing. definitely i am missing something. first group start from 2 to 6 and second group start from 7 to 11. so i am expecting two expand collapse icon for two group but one one is coming.
see a sample screen shot where two expand collapse group is showing. in the screen shot i provide two arrow just to point out i want same two expand collapse icon in my excel. please tell me what is missing in my code. thanks
Continue reading...
I am trying to learn how to do multi level row & column collapse and My code is working. the only issue is multiple expand and collapse +/- symbol not showing in excel file after generating. please tell me what is missing in my code. here is my code.
var datatable = new DataTable("tblData");
datatable.Columns.AddRange(new[]
{
new DataColumn("Header", typeof (string)),
new DataColumn("Col1", typeof (int)),
new DataColumn("Col2", typeof (int)),
new DataColumn("Col3", typeof (object))
});
for (var i = 0; i < 10; i++)
{
var row = datatable.NewRow();
row[0] = String.Format("Header {0}", i);
row[1] = i;
row[2] = i * 10;
row[3] = Path.GetRandomFileName();
datatable.Rows.Add(row);
}
//Create a test file
var fi = new FileInfo(@"d:\Row_Grouping_Test2.xlsx");
if (fi.Exists)
fi.Delete();
using (var pck = new ExcelPackage(fi))
{
var worksheet = pck.Workbook.Worksheets.Add("Sheet1");
worksheet.Cells.LoadFromDataTable(datatable, true);
worksheet.Cells["B12"].Formula = "SUM(B2:B11)";
worksheet.Cells["C12"].Formula = "SUM(C2:C11)";
//Row Group 1
for (var i = 2; i <= 6; i++)
{
worksheet.Row(i).OutlineLevel = 1;
//worksheet.Row(i).Collapsed = true;
}
//Row Group 2
for (var i = 7; i <= 11; i++)
{
worksheet.Row(i).OutlineLevel = 1;
//worksheet.Row(i).Collapsed = true;
}
//Column Group
for (var i = 2; i <= 4; i++)
{
worksheet.Column(i).OutlineLevel = 1;
//worksheet.Column(i).Collapsed = true;
}
pck.Save();
}
There is two row group 1 and 2. for 1 group expand collapse icon is showing but for group 2 no expand collapse icon showing. definitely i am missing something. first group start from 2 to 6 and second group start from 7 to 11. so i am expecting two expand collapse icon for two group but one one is coming.
see a sample screen shot where two expand collapse group is showing. in the screen shot i provide two arrow just to point out i want same two expand collapse icon in my excel. please tell me what is missing in my code. thanks
Continue reading...