Skip to content

Commit

Permalink
Editing Excel cells
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurmitha4004 committed Jul 11, 2024
1 parent c56a6f7 commit 0d9423e
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Editing Excel cells/Find/NET Standard/Find/Find.sln
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}") = "Find", "Find\Find.csproj", "{32D01DA5-E6C0-434C-A768-DC6CCEDAB49C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{32D01DA5-E6C0-434C-A768-DC6CCEDAB49C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32D01DA5-E6C0-434C-A768-DC6CCEDAB49C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32D01DA5-E6C0-434C-A768-DC6CCEDAB49C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32D01DA5-E6C0-434C-A768-DC6CCEDAB49C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A8C006AC-8AA4-44A1-93DF-1B05E5C58C61}
EndGlobalSection
EndGlobal
Binary file not shown.
14 changes: 14 additions & 0 deletions Editing Excel cells/Find/NET Standard/Find/Find/Find.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

</Project>
52 changes: 52 additions & 0 deletions Editing Excel cells/Find/NET Standard/Find/Find/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Syncfusion.XlsIO;

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

//Searches for the given string within the text of worksheet
IRange[] result1 = worksheet.FindAll("Gill", ExcelFindType.Text);

//Searches for the given string within the text of worksheet
IRange[] result2 = worksheet.FindAll(700, ExcelFindType.Number);

//Searches for the given string in formulas
IRange[] result3 = worksheet.FindAll("=SUM(F10:F11)", ExcelFindType.Formula);

//Searches for the given string in calculated value, number and text
IRange[] result4 = worksheet.FindAll("41", ExcelFindType.Values);

//Searches for the given string in comments
IRange[] result5 = worksheet.FindAll("Desk", ExcelFindType.Comments);

//Searches for the given string within the text of worksheet and case matched
IRange[] result6 = worksheet.FindAll("Pen Set", ExcelFindType.Text, ExcelFindOptions.MatchCase);

//Searches for the given string within the text of worksheet and the entire cell content matching to search text
IRange[] result7 = worksheet.FindAll("5", ExcelFindType.Text, ExcelFindOptions.MatchEntireCellContent);

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

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo("Find.xlsx")
{
UseShellExecute = true
};
process.Start();
}
}
}
}
25 changes: 25 additions & 0 deletions Editing Excel cells/Replace/NET Standard/Replace/Replace.sln
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}") = "Replace", "Replace\Replace.csproj", "{5B547108-737B-4DBE-A156-B616BF30E42C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5B547108-737B-4DBE-A156-B616BF30E42C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B547108-737B-4DBE-A156-B616BF30E42C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B547108-737B-4DBE-A156-B616BF30E42C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B547108-737B-4DBE-A156-B616BF30E42C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E9452216-B49D-4439-B2C9-73A7B5C42CEC}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Syncfusion.XlsIO;

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

//Replaces the given string with another string
worksheet.Replace("Wilson", "William");

//Replaces the given string with another string on match case
worksheet.Replace("4.99", "4.90", ExcelFindOptions.MatchCase);

//Replaces the given string with another string matching entire cell content to the search word
worksheet.Replace("Pen Set", "Pen", ExcelFindOptions.MatchEntireCellContent);

//Replaces the given string with DateTime value
worksheet.Replace("DateValue",DateTime.Now);

//Replaces the given string with Array
worksheet.Replace("Central", new string[] { "Central", "East" }, true);

//Saving the workbook as stream
FileStream stream = new FileStream("Replace.xlsx", FileMode.Create, FileAccess.ReadWrite);
workbook.Version = ExcelVersion.Xlsx;
workbook.SaveAs(stream);
stream.Dispose();

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

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

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

</Project>

0 comments on commit 0d9423e

Please sign in to comment.