Skip to content

Commit 4d86886

Browse files
committed
Slicer
1 parent 2aaa907 commit 4d86886

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36109.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateTableSlicer", "CreateTableSlicer\CreateTableSlicer.csproj", "{FB4FEB74-2019-43D4-A115-50F803A3BFB7}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{FB4FEB74-2019-43D4-A115-50F803A3BFB7}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {9788A549-8F0C-425D-94BA-DDDCD26FC01B}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Create_Slicer</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.XlsIO.NET" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Data\*">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
<None Update="Output\*">
18+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19+
</None>
20+
</ItemGroup>
21+
22+
</Project>
23+
24+
25+
12.2 KB
Binary file not shown.

Use Cases/Slicer/CreateTableSlicer/Output/.gitkeep

Whitespace-only changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.IO;
2+
using Syncfusion.XlsIO;
3+
4+
namespace CreateTableSlicer
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
// Initialize ExcelEngine
11+
using (ExcelEngine excelEngine = new ExcelEngine())
12+
{
13+
// Set the default application version as Xlsx
14+
IApplication application = excelEngine.Excel;
15+
application.DefaultVersion = ExcelVersion.Xlsx;
16+
17+
//Open existing workbook with data
18+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic);
19+
20+
//Access first worksheet from the workbook.
21+
IWorksheet sheet = workbook.Worksheets[0];
22+
23+
//Access the table.
24+
IListObject table = sheet.ListObjects[0];
25+
26+
27+
//Add Slicer to the Requester column(4th column) from the table at 11th row and 2nd column.
28+
sheet.Slicers.Add(table, 4, 11, 2);
29+
30+
// Modify Slicer properties
31+
ISlicer slicer = sheet.Slicers[0];
32+
33+
// Set Slicer caption, name, and size
34+
slicer.Caption = "Select Assignee";
35+
slicer.Name = "Assignees";
36+
slicer.Height = 200;
37+
slicer.Width = 200;
38+
39+
//Apply built-in style for requester slicer
40+
slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark1;
41+
42+
// Add Slicer to the Status column (5th column) from the table at 11th row and 4th column.
43+
sheet.Slicers.Add(table, 5, 11, 4);
44+
45+
// Modify Slicer properties
46+
slicer = sheet.Slicers[1];
47+
slicer.Caption = "Select Status";
48+
slicer.Name = "Status";
49+
slicer.Height = 200;
50+
slicer.Width = 200;
51+
52+
53+
//Apply built-in style for status slicer
54+
slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleLight2;
55+
56+
//Save the workbook
57+
workbook.SaveAs(Path.GetFullPath("Output/CreateTableSlicer.xlsx"));
58+
}
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)