Skip to content

Commit 2f04906

Browse files
authored
Merge pull request #209 from SyncfusionExamples/964291-ConsoleExcelToPDFExample
964291-Add UG for converting Excel to PDF in Console application
2 parents 4bf6ee3 + 5634c93 commit 2f04906

File tree

13 files changed

+267
-0
lines changed

13 files changed

+267
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36127.28 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertExcelToPDF", "ConvertExcelToPDF\ConvertExcelToPDF.csproj", "{25CF80BC-DCE7-447F-8458-1C207B68A31F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{25CF80BC-DCE7-447F-8458-1C207B68A31F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{25CF80BC-DCE7-447F-8458-1C207B68A31F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{25CF80BC-DCE7-447F-8458-1C207B68A31F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{25CF80BC-DCE7-447F-8458-1C207B68A31F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {EBA15DC6-9DD6-455E-94E3-13C920C3DB5F}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="Syncfusion.Compression.Base" publicKeyToken="3d67ed1f87d44c89" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-100.2460.1.0" newVersion="100.2460.1.0" />
11+
</dependentAssembly>
12+
</assemblyBinding>
13+
</runtime>
14+
</configuration>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{25CF80BC-DCE7-447F-8458-1C207B68A31F}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>ConvertExcelToPDF</RootNamespace>
10+
<AssemblyName>ConvertExcelToPDF</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Syncfusion.Compression.Base, Version=100.2460.1.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Syncfusion.Compression.Base.100.2.38\lib\net462\Syncfusion.Compression.Base.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Syncfusion.ExcelToPdfConverter.Base, Version=29.2462.11.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Syncfusion.ExcelToPdfConverter.WinForms.29.2.11\lib\net462\Syncfusion.ExcelToPdfConverter.Base.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Syncfusion.Licensing, Version=29.2462.11.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
43+
<HintPath>..\packages\Syncfusion.Licensing.29.2.11\lib\net462\Syncfusion.Licensing.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Syncfusion.Pdf.Base, Version=29.2462.11.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
46+
<HintPath>..\packages\Syncfusion.Pdf.WinForms.29.2.11\lib\net462\Syncfusion.Pdf.Base.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Syncfusion.XlsIO.Base, Version=29.2462.11.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
49+
<HintPath>..\packages\Syncfusion.XlsIO.WinForms.29.2.11\lib\net462\Syncfusion.XlsIO.Base.dll</HintPath>
50+
</Reference>
51+
<Reference Include="System" />
52+
<Reference Include="System.Core" />
53+
<Reference Include="System.Xml.Linq" />
54+
<Reference Include="System.Data.DataSetExtensions" />
55+
<Reference Include="Microsoft.CSharp" />
56+
<Reference Include="System.Data" />
57+
<Reference Include="System.Net.Http" />
58+
<Reference Include="System.Xml" />
59+
</ItemGroup>
60+
<ItemGroup>
61+
<Compile Include="Program.cs" />
62+
<Compile Include="Properties\AssemblyInfo.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="App.config" />
66+
<None Include="packages.config" />
67+
</ItemGroup>
68+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
69+
</Project>
Binary file not shown.

Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Output/.gitkeep

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Syncfusion.ExcelToPdfConverter;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.XlsIO;
4+
using System.IO;
5+
6+
namespace ConvertExcelToPDF
7+
{
8+
class Program
9+
{
10+
public static void Main(string[] args)
11+
{
12+
using (ExcelEngine excelEngine = new ExcelEngine())
13+
{
14+
IApplication application = excelEngine.Excel;
15+
application.DefaultVersion = ExcelVersion.Xlsx;
16+
FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
17+
IWorkbook workbook = application.Workbooks.Open(excelStream);
18+
19+
//Initialize ExcelToPdfConverter
20+
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
21+
22+
//Initialize PDF document
23+
PdfDocument pdfDocument = new PdfDocument();
24+
25+
//Convert Excel document to PDF document
26+
pdfDocument = converter.Convert();
27+
28+
//Save the converted PDF document
29+
pdfDocument.Save("Sample.pdf");
30+
}
31+
}
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("ConvertExcelToPDF")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ConvertExcelToPDF")]
13+
[assembly: AssemblyCopyright("Copyright © 2025")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("25cf80bc-dce7-447f-8458-1c207b68a31f")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Syncfusion.Compression.Base" version="*" targetFramework="net48" />
4+
<package id="Syncfusion.ExcelToPdfConverter.WinForms" version="*" targetFramework="net48" />
5+
<package id="Syncfusion.Licensing" version="*" targetFramework="net48" />
6+
<package id="Syncfusion.Pdf.WinForms" version="*" targetFramework="net48" />
7+
<package id="Syncfusion.XlsIO.WinForms" version="*" targetFramework="net48" />
8+
</packages>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36127.28 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertExcelToPDF", "ConvertExcelToPDF\ConvertExcelToPDF.csproj", "{A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A57344D4-3ED1-4B33-B0C3-EE728A62FDFD}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {333E4BFE-C711-4343-889E-73D015273596}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Output\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)