diff --git a/Use Cases/Slicer/CreateTableSlicer.sln b/Use Cases/Slicer/CreateTableSlicer.sln new file mode 100644 index 00000000..6cd8a735 --- /dev/null +++ b/Use Cases/Slicer/CreateTableSlicer.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36109.1 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateTableSlicer", "CreateTableSlicer\CreateTableSlicer.csproj", "{FB4FEB74-2019-43D4-A115-50F803A3BFB7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9788A549-8F0C-425D-94BA-DDDCD26FC01B} + EndGlobalSection +EndGlobal diff --git a/Use Cases/Slicer/CreateTableSlicer/CreateTableSlicer.csproj b/Use Cases/Slicer/CreateTableSlicer/CreateTableSlicer.csproj new file mode 100644 index 00000000..fc4b87bf --- /dev/null +++ b/Use Cases/Slicer/CreateTableSlicer/CreateTableSlicer.csproj @@ -0,0 +1,25 @@ + + + + Exe + net8.0 + Create_Slicer + + + + + + + + + Always + + + Always + + + + + + + diff --git a/Use Cases/Slicer/CreateTableSlicer/Data/InputTemplate.xlsx b/Use Cases/Slicer/CreateTableSlicer/Data/InputTemplate.xlsx new file mode 100644 index 00000000..76435b11 Binary files /dev/null and b/Use Cases/Slicer/CreateTableSlicer/Data/InputTemplate.xlsx differ diff --git a/Use Cases/Slicer/CreateTableSlicer/Output/.gitkeep b/Use Cases/Slicer/CreateTableSlicer/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Use Cases/Slicer/CreateTableSlicer/Program.cs b/Use Cases/Slicer/CreateTableSlicer/Program.cs new file mode 100644 index 00000000..dc513d08 --- /dev/null +++ b/Use Cases/Slicer/CreateTableSlicer/Program.cs @@ -0,0 +1,61 @@ +using System.IO; +using Syncfusion.XlsIO; + +namespace CreateTableSlicer +{ + class Program + { + static void Main(string[] args) + { + // Initialize ExcelEngine + using (ExcelEngine excelEngine = new ExcelEngine()) + { + // Set the default application version as Xlsx + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Open existing workbook with data + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); + + //Access first worksheet from the workbook. + IWorksheet sheet = workbook.Worksheets[0]; + + //Access the table. + IListObject table = sheet.ListObjects[0]; + + + //Add Slicer to the Requester column(4th column) from the table at 11th row and 2nd column. + sheet.Slicers.Add(table, 4, 11, 2); + + // Modify Slicer properties + ISlicer slicer = sheet.Slicers[0]; + + // Set Slicer caption, name, and size + slicer.Caption = "Select Assignee"; + slicer.Name = "Assignees"; + slicer.Height = 200; + slicer.Width = 200; + + //Apply built-in style for requester slicer + slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark1; + + // Add Slicer to the Status column (5th column) from the table at 11th row and 4th column. + sheet.Slicers.Add(table, 5, 11, 4); + + // Modify Slicer properties + slicer = sheet.Slicers[1]; + slicer.Caption = "Select Status"; + slicer.Name = "Status"; + slicer.Height = 200; + slicer.Width = 200; + + + //Apply built-in style for status slicer + slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleLight2; + + //Save the workbook + workbook.SaveAs(Path.GetFullPath("Output/CreateTableSlicer.xlsx")); + } + } + } +}