Skip to content

Commit

Permalink
FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurmitha4004 committed Oct 18, 2024
1 parent 6f6c0c3 commit 2384e5b
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
25 changes: 25 additions & 0 deletions FAQ/Multithreading/.NET/Multithreading/Multithreading.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}") = "Multithreading", "Multithreading\Multithreading.csproj", "{FF011E2F-22A0-4FE9-927E-E19D6943A39F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FF011E2F-22A0-4FE9-927E-E19D6943A39F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF011E2F-22A0-4FE9-927E-E19D6943A39F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF011E2F-22A0-4FE9-927E-E19D6943A39F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF011E2F-22A0-4FE9-927E-E19D6943A39F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3FF7195C-8AA0-4979-9884-45A22FE9BCE4}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="27.1.53" />
</ItemGroup>

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

</Project>
Empty file.
58 changes: 58 additions & 0 deletions FAQ/Multithreading/.NET/Multithreading/Multithreading/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Syncfusion.XlsIO;
using Syncfusion.XlsIORenderer;
using Syncfusion.Pdf;

namespace Multithreading
{
class MultiThreading
{
//Defines the number of threads to be created
private const int ThreadCount = 1000;
public static void Main()
{
//Create an array of threads based on the ThreadCount
Thread[] threads = new Thread[ThreadCount];
for (int i = 0; i < ThreadCount; i++)
{
threads[i] = new Thread(ReadEditConvertExcel);
threads[i].Start();
}

//Ensure all threads complete by calling Join on each thread
for (int i = 0; i < ThreadCount; i++)
{
threads[i].Join();
}
}

//Method to convert Excel to PDF
static void ReadEditConvertExcel()
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2016;
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
inputStream.Close();
IWorksheet sheet = workbook.Worksheets[0];

//Add text, formula, and number in the worksheet
sheet.Range["A1"].Text = "Hello World" + DateTime.Now;
Console.WriteLine(sheet.Range["A1"].Text);
sheet.Range["A2"].Formula = "=Now()";
sheet.Range["A3"].Number = 12345;

//Convert the Excel workbook to PDF
XlsIORenderer xlsIORenderer = new XlsIORenderer();
PdfDocument pdfDocument = xlsIORenderer.ConvertToPDF(workbook);

//Save the PDF document
MemoryStream fileStream = new MemoryStream();
pdfDocument.Save(fileStream);
fileStream.Close();
pdfDocument.Dispose();
}
}
}
}
1 change: 1 addition & 0 deletions FAQ/Multithreading/.NET/Multithreading/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Does XlsIO library support multithreading and thread-safe?

0 comments on commit 2384e5b

Please sign in to comment.