-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f6c0c3
commit 2384e5b
Showing
6 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+6.05 KB
FAQ/Multithreading/.NET/Multithreading/Multithreading/Data/InputTemplate.xlsx
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
FAQ/Multithreading/.NET/Multithreading/Multithreading/Multithreading.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
58
FAQ/Multithreading/.NET/Multithreading/Multithreading/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Does XlsIO library support multithreading and thread-safe? |