Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions FAQ/Barcode/.NET/Add Barcode/Barcode.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.35506.116 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Barcode", "Barcode\Barcode.csproj", "{97F53687-3D4D-419F-8A16-D6C24345A2FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{97F53687-3D4D-419F-8A16-D6C24345A2FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97F53687-3D4D-419F-8A16-D6C24345A2FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97F53687-3D4D-419F-8A16-D6C24345A2FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97F53687-3D4D-419F-8A16-D6C24345A2FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions FAQ/Barcode/.NET/Add Barcode/Barcode/Barcode.csproj
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.XlsIO.Net.Core" Version="*" />
</ItemGroup>

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

</Project>
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.
Empty file.
36 changes: 36 additions & 0 deletions FAQ/Barcode/.NET/Add Barcode/Barcode/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.IO;
using Syncfusion.XlsIO;

namespace AddBarcode
{
class Program
{
static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];

// Load barcodes from local files
FileStream barcode1 = new FileStream("Data/Barcode1.png", FileMode.Open, FileAccess.Read);
FileStream barcode2 = new FileStream("Data/Barcode2.png", FileMode.Open, FileAccess.Read);
worksheet.Pictures.AddPicture(1, 1, barcode1);
worksheet.Pictures.AddPicture(15, 1, barcode2);
worksheet.Pictures.AddPicture(1, 10, barcode1);
worksheet.Pictures.AddPicture(15, 10, barcode2);

// Save to file system
FileStream stream = new FileStream("Output/Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.Close();
excelEngine.Dispose();
}

}

}
}
42 changes: 42 additions & 0 deletions FAQ/Barcode/.NET/Add Barcode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# How to add Barcode in Excel document using C#?

Step 1: Create a New C# Console Application Project.

Step 2: Name the Project.

Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).

Step 4: Include the following namespaces in the **Program.cs** file.

```csharp
using System;
using System.IO;
using Syncfusion.XlsIO;
```

Step 5: Include the below code snippet in **Program.cs** to add Barcode in Excel document.

```csharp
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];

// Load barcodes from local files
FileStream barcode1 = new FileStream("Data/Barcode1.png", FileMode.Open, FileAccess.Read);
FileStream barcode2 = new FileStream("Data/Barcode2.png", FileMode.Open, FileAccess.Read);
worksheet.Pictures.AddPicture(1, 1, barcode1);
worksheet.Pictures.AddPicture(15, 1, barcode2);
worksheet.Pictures.AddPicture(1, 10, barcode1);
worksheet.Pictures.AddPicture(15, 10, barcode2);

// Save to file system
FileStream stream = new FileStream("Output/Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.Close();
excelEngine.Dispose();
}
```