Skip to content

Commit

Permalink
Use Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurmitha4004 committed Jul 5, 2024
1 parent 2437932 commit 715b474
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34310.174
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Email Validation", "Email Validation\Email Validation.csproj", "{E7DD6085-35DA-4553-8CB0-92883B3EAF2E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E7DD6085-35DA-4553-8CB0-92883B3EAF2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7DD6085-35DA-4553-8CB0-92883B3EAF2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7DD6085-35DA-4553-8CB0-92883B3EAF2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7DD6085-35DA-4553-8CB0-92883B3EAF2E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {11C944C7-201E-459B-BE41-AA09300206AD}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Email_Validation</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="26.1.40" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Syncfusion.XlsIO;

namespace Email_Validation
{
class Program
{
public static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet worksheet = workbook.Worksheets[0];

//Data validation for email format
IDataValidation validation = worksheet.Range["G2:G7"].DataValidation;
validation.AllowType = ExcelDataType.Formula;
validation.FirstFormula = "=AND(ISNUMBER(SEARCH(\"@\", G2:G7)), ISNUMBER(SEARCH(\".\", G2:G7, SEARCH(\"@\", G2:G7))))";

//Shows the error message
validation.ErrorBoxText = "Please enter a valid Email address.";
validation.ErrorBoxTitle = "Invalid Email Format";
validation.PromptBoxText = "Enter an Email address";
validation.IsPromptBoxVisible = true;
validation.ShowPromptBox = true;

//Saving the workbook as stream
FileStream OutputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(OutputStream);

//Dispose stream
inputStream.Dispose();
OutputStream.Dispose();

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo("Output.xlsx")
{
UseShellExecute = true
};
process.Start();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34310.174
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "URL Validation", "URL Validation\URL Validation.csproj", "{21D0DE4C-292D-49AC-97EB-A31B92219C4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{21D0DE4C-292D-49AC-97EB-A31B92219C4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21D0DE4C-292D-49AC-97EB-A31B92219C4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21D0DE4C-292D-49AC-97EB-A31B92219C4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21D0DE4C-292D-49AC-97EB-A31B92219C4D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {20A67F31-A0B2-456D-B945-419215D92E71}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Syncfusion.XlsIO;

namespace URL_Validation
{
class Program
{
public static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet worksheet = workbook.Worksheets[0];

// Data validation for url format
IDataValidation validation = worksheet.Range["G2:G7"].DataValidation;
validation.AllowType = ExcelDataType.Formula;
validation.FirstFormula = "=AND(ISNUMBER(SEARCH(\"://\", G2:G7)), ISNUMBER(SEARCH(\".\", G2:G7, SEARCH(\"://\", G2:G7))))";

//Shows the error message
validation.ErrorBoxText = "Please enter a valid URL.";
validation.ErrorBoxTitle = "Invalid URL Format";
validation.PromptBoxText = "Enter a valid URL";
validation.IsPromptBoxVisible = true;
validation.ShowPromptBox = true;

//Saving the workbook as stream
FileStream OutputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(OutputStream);

//Dispose stream
inputStream.Dispose();
OutputStream.Dispose();

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo("Output.xlsx")
{
UseShellExecute = true
};
process.Start();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>URL_Validation</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="26.1.40" />
</ItemGroup>

</Project>

0 comments on commit 715b474

Please sign in to comment.