Skip to content

Commit a89d7a8

Browse files
authored
Merge pull request #199 from SyncfusionExamples/264585-ClearFiltersTable
264585-How to clear filters from the table in XlsIO
2 parents 978e497 + 62231e7 commit a89d7a8

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-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.36127.28 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clear filter from table", "Clear filter from table\Clear filter from table.csproj", "{CF798281-D9F5-47BB-986E-3F9EA4478D43}"
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+
{CF798281-D9F5-47BB-986E-3F9EA4478D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{CF798281-D9F5-47BB-986E-3F9EA4478D43}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{CF798281-D9F5-47BB-986E-3F9EA4478D43}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{CF798281-D9F5-47BB-986E-3F9EA4478D43}.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 = {A5816C6A-9F3D-49D4-BC70-E99F3FB75C38}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Clear_filter_from_table</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\*">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\*">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>

Use Cases/Hide filter from table/.NET/Hide filter from table/Hide filter from table/Output/.gitkeep

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Syncfusion.XlsIO;
2+
3+
namespace Clear_Filter_From_Table
4+
{
5+
class Program
6+
{
7+
public static void Main(string[] args)
8+
{
9+
using (ExcelEngine excelEngine = new ExcelEngine())
10+
{
11+
IApplication application = excelEngine.Excel;
12+
application.DefaultVersion = ExcelVersion.Xlsx;
13+
14+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
15+
IWorkbook workbook = application.Workbooks.Open(inputStream);
16+
IWorksheet worksheet = workbook.Worksheets[0];
17+
18+
//Access the first table (ListObject) in the worksheet
19+
IListObject table = worksheet.ListObjects[0];
20+
21+
//Clear filters from the table
22+
table.ShowAutoFilter = false;
23+
24+
//Saving the workbook
25+
FileStream outputStream = new FileStream(Path.GetFullPath("Output.xlsx"), FileMode.Create, FileAccess.ReadWrite);
26+
workbook.SaveAs(outputStream);
27+
28+
//Dispose streams
29+
outputStream.Dispose();
30+
inputStream.Dispose();
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)