Skip to content

Commit 3380cd5

Browse files
authored
Merge pull request #226 from SyncfusionExamples/978264-CustomFilterStringType
978264-FAQ for how to apply custom filtering on string data types
2 parents eaec355 + 3401a6d commit 3380cd5

File tree

6 files changed

+125
-0
lines changed

6 files changed

+125
-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.36221.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomFilterStringType", "CustomFilterStringType\CustomFilterStringType.csproj", "{F22EFEC1-0351-48AC-B50E-04211BEBD213}"
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+
{F22EFEC1-0351-48AC-B50E-04211BEBD213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F22EFEC1-0351-48AC-B50E-04211BEBD213}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F22EFEC1-0351-48AC-B50E-04211BEBD213}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F22EFEC1-0351-48AC-B50E-04211BEBD213}.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 = {577F87AB-4F9E-40F5-8D93-796229613048}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Output\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
19+
20+
</Project>
9.73 KB
Binary file not shown.

FAQ/Filtering/.NET/Custom Filter String Type/CustomFilterStringType/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+
using System.IO;
3+
4+
class Program
5+
{
6+
public static void Main(string[] args)
7+
{
8+
using (ExcelEngine excelEngine = new ExcelEngine())
9+
{
10+
IApplication application = excelEngine.Excel;
11+
application.DefaultVersion = ExcelVersion.Xlsx;
12+
FileStream inputStream = new FileStream(Path.GetFullPath(@"../../../Data/Input.xlsx"), FileMode.Open, FileAccess.Read);
13+
IWorkbook workbook = application.Workbooks.Open(inputStream);
14+
IWorksheet worksheet = workbook.Worksheets[0];
15+
16+
//Creating an AutoFilter
17+
worksheet.AutoFilters.FilterRange = worksheet.Range["A1:A11"];
18+
IAutoFilter filter = worksheet.AutoFilters[0];
19+
20+
//Specifying first condition
21+
IAutoFilterCondition firstCondition = filter.FirstCondition;
22+
firstCondition.ConditionOperator = ExcelFilterCondition.DoesNotContain;
23+
firstCondition.String = "1000.00";
24+
25+
//Saving the workbook
26+
FileStream outputStream = new FileStream(Path.GetFullPath("../../../Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
27+
workbook.SaveAs(outputStream);
28+
29+
//Dispose streams
30+
outputStream.Dispose();
31+
inputStream.Dispose();
32+
}
33+
}
34+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# How to apply custom filtering to string data types using XlsIO?
2+
3+
Step 1: Create a New C# Console Application Project.
4+
5+
Step 2: Name the Project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
11+
```csharp
12+
using System;
13+
using System.IO;
14+
using Syncfusion.XlsIO;
15+
```
16+
17+
Step 5: Include the below code snippet in **Program.cs** to apply custom filtering to string data types using XlsIO.
18+
19+
```csharp
20+
using (ExcelEngine excelEngine = new ExcelEngine())
21+
{
22+
IApplication application = excelEngine.Excel;
23+
application.DefaultVersion = ExcelVersion.Xlsx;
24+
FileStream inputStream = new FileStream(Path.GetFullPath(@"../../../Data/Input.xlsx"), FileMode.Open, FileAccess.Read);
25+
IWorkbook workbook = application.Workbooks.Open(inputStream);
26+
IWorksheet worksheet = workbook.Worksheets[0];
27+
28+
//Creating an AutoFilter
29+
worksheet.AutoFilters.FilterRange = worksheet.Range["A1:A11"];
30+
IAutoFilter filter = worksheet.AutoFilters[0];
31+
32+
//Specifying first condition
33+
IAutoFilterCondition firstCondition = filter.FirstCondition;
34+
firstCondition.ConditionOperator = ExcelFilterCondition.DoesNotContain;
35+
firstCondition.String = "1000.00";
36+
37+
//Saving the workbook
38+
FileStream outputStream = new FileStream(Path.GetFullPath("../../../Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
39+
workbook.SaveAs(outputStream);
40+
41+
//Dispose streams
42+
outputStream.Dispose();
43+
inputStream.Dispose();
44+
}
45+
```
46+

0 commit comments

Comments
 (0)