Skip to content

Commit

Permalink
Playground Button
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurmitha4004 committed Nov 20, 2024
1 parent 1cfeba9 commit 9533f81
Show file tree
Hide file tree
Showing 35 changed files with 521 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35417.141 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Custom Validation", "Custom Validation\Custom Validation.csproj", "{9DF53F0C-052E-4760-AF98-06C06305121D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9DF53F0C-052E-4760-AF98-06C06305121D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DF53F0C-052E-4760-AF98-06C06305121D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DF53F0C-052E-4760-AF98-06C06305121D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DF53F0C-052E-4760-AF98-06C06305121D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Syncfusion.XlsIO;

namespace Custom_Validation
{
class Program
{
public static void Main(string[] args)
{
// Initialize Excel engine and application.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

// Create a workbook and worksheet.
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];

// Data validation for custom data.
IDataValidation validation = worksheet.Range["A3"].DataValidation;
worksheet.Range["A1"].Text = "Enter the value greater than 10 in A1";
worksheet.Range["A2"].Text = "Enter the text in A3";
worksheet.Range["A1"].AutofitColumns();
validation.AllowType = ExcelDataType.Formula;
validation.FirstFormula = "=A1>10";

// Show the error message.
validation.ShowErrorBox = true;
validation.ErrorBoxText = "A1 value is less than 10";
validation.ErrorBoxTitle = "ERROR";
validation.PromptBoxText = "Custom Data Validation";
validation.ShowPromptBox = true;

// Save the Excel document.
FileStream outputStream = new FileStream(Path.GetFullPath("Output/CustomValidation.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
}
}
}
}
22 changes: 22 additions & 0 deletions Excel to Text/Excel to Text/.NET/Excel to Text/Excel to Text.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35417.141 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excel to Text", "Excel to Text\Excel to Text.csproj", "{6657A512-E336-4097-8D5E-BF4A998D261A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6657A512-E336-4097-8D5E-BF4A998D261A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6657A512-E336-4097-8D5E-BF4A998D261A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6657A512-E336-4097-8D5E-BF4A998D261A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6657A512-E336-4097-8D5E-BF4A998D261A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

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

namespace Excel_to_Text
{
class Program
{
public static void Main(string[] args)
{
// Initialize Excel engine and application.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

// Open an existing workbook.
FileStream inputStream = new FileStream(Path.GetFullPath("Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);

// Save the workbook in .txt format with space (" ") as the delimiter.
using FileStream outputStream = new FileStream(Path.GetFullPath("Output/Excel to Text.txt"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(outputStream, " ");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35417.141 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Import Array", "Import Array\Import Array.csproj", "{686B45E1-3585-408C-B498-8F90C8379DD5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{686B45E1-3585-408C-B498-8F90C8379DD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{686B45E1-3585-408C-B498-8F90C8379DD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{686B45E1-3585-408C-B498-8F90C8379DD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{686B45E1-3585-408C-B498-8F90C8379DD5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Syncfusion.XlsIO;

namespace Import_Array
{
class Program
{
public static void Main(string[] args)
{
// Initialize Excel engine and application.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

// Open an existing workbook.
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);

// Create Template Marker Processor.
ITemplateMarkersProcessor marker = workbook.CreateTemplateMarkersProcessor();

// Insert Array Horizontally.
string[] names = { "Mickey", "Donald", "Tom", "Jerry" };
string[] descriptions = { "Mouse", "Duck", "Cat", "Mouse" };

// Add collections to the marker variables where the name should match with input template.
marker.AddVariable("Names", names);
marker.AddVariable("Descriptions", descriptions);

// Process the markers in the template.
marker.ApplyMarkers();

// Saving the workbook.
FileStream outputStream = new FileStream(Path.GetFullPath("Output/ImportArray.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35417.141 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Import Collection", "Import Collection\Import Collection.csproj", "{8E2BF7A1-1349-4BC9-97C9-137105EE4C35}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8E2BF7A1-1349-4BC9-97C9-137105EE4C35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E2BF7A1-1349-4BC9-97C9-137105EE4C35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E2BF7A1-1349-4BC9-97C9-137105EE4C35}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E2BF7A1-1349-4BC9-97C9-137105EE4C35}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Syncfusion.Licensing;
using Syncfusion.XlsIO;

namespace Import_Collection
{
class Program
{
public static void Main(string[] args)
{
// Initialize Excel engine and application.
using ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

// Open an existing workbook.
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);

// Create Template Marker Processor.
ITemplateMarkersProcessor marker = workbook.CreateTemplateMarkersProcessor();

// Get the data into collection object.
IList<Report> reports = GetSalesReports();

// Add collections to the marker variables where the name should match with input template.
marker.AddVariable("Reports", reports);

//Applying Markers
marker.ApplyMarkers();

// Saving the workbook.
FileStream outputStream = new FileStream(Path.GetFullPath("Output/ImportCollection.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
inputStream.Dispose();
outputStream.Dispose();
}
// Gets a list of sales reports.
private static List<Report> GetSalesReports()
{
List<Report> reports = new List<Report>();
reports.Add(new Report("Andy Bernard", "45000", "58000", 29, "Data/Andy.png"));
reports.Add(new Report("Jim Halpert", "34000", "65000", 91, "Data/Jim.png"));
reports.Add(new Report("Karen Fillippelli", "75000", "64000", -14, "Data/Karen.png"));
reports.Add(new Report("Phyllis Lapin", "56500", "33600", -40, "Data/Phyllis.png"));
reports.Add(new Report("Stanley Hudson", "46500", "52000", 12, "Data/Stanley.png"));
return reports;
}

// Sales report.
public class Report
{
public string SalesPerson { get; set; }
public string SalesJanJun { get; set; }
public string SalesJulDec { get; set; }
public int Change { get; set; }
public byte[] Image { get; set; }

public Report(string name, string janToJun, string julToDec, int change, string imagePath)
{
SalesPerson = name;
SalesJanJun = janToJun;
SalesJulDec = julToDec;
Change = change;
Image = File.ReadAllBytes(imagePath);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void Main(string[] args)
IWorkbook workbook = application.Workbooks.Open(inputStream, "\t");

//Save the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite);
FileStream outputStream = new FileStream(Path.GetFullPath("Output/TSV to Excel.xlsx"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(outputStream);

//Dispose streams
Expand Down
Loading

0 comments on commit 9533f81

Please sign in to comment.