-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from SyncfusionExamples/840156-ExcelToPDF
841507-Adding the samples for Excel to PDF Conversion in WinForms
- Loading branch information
Showing
13 changed files
with
529 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF.sln
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.5.33516.290 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Excel-to-PDF", "Convert-Excel-to-PDF\Convert-Excel-to-PDF.csproj", "{A97F8CB2-EC51-4F26-8484-5E6C9CEF5371}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A97F8CB2-EC51-4F26-8484-5E6C9CEF5371}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A97F8CB2-EC51-4F26-8484-5E6C9CEF5371}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A97F8CB2-EC51-4F26-8484-5E6C9CEF5371}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A97F8CB2-EC51-4F26-8484-5E6C9CEF5371}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {3284DD27-BAF2-4847-8F36-CF85525FE23B} | ||
EndGlobalSection | ||
EndGlobal |
6 changes: 6 additions & 0 deletions
6
Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/App.config
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
97 changes: 97 additions & 0 deletions
97
...arted/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Convert-Excel-to-PDF.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,97 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{A97F8CB2-EC51-4F26-8484-5E6C9CEF5371}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>Convert_Excel_to_PDF</RootNamespace> | ||
<AssemblyName>Convert-Excel-to-PDF</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Syncfusion.Compression.Base, Version=22.2460.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.Compression.Base.22.2.5\lib\net46\Syncfusion.Compression.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.ExcelToPdfConverter.Base, Version=22.2460.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.ExcelToPdfConverter.WinForms.22.2.5\lib\net46\Syncfusion.ExcelToPdfConverter.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.Licensing, Version=22.2460.5.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.Licensing.22.2.5\lib\net46\Syncfusion.Licensing.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.Pdf.Base, Version=22.2460.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.Pdf.WinForms.22.2.5\lib\net46\Syncfusion.Pdf.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.XlsIO.Base, Version=22.2460.5.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.XlsIO.WinForms.22.2.5\lib\net46\Syncfusion.XlsIO.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Form1.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="Form1.Designer.cs"> | ||
<DependentUpon>Form1.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<None Include="Data\InputTemplate.xlsx" /> | ||
<None Include="packages.config" /> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
Binary file added
BIN
+12 KB
...g Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Data/InputTemplate.xlsx
Binary file not shown.
62 changes: 62 additions & 0 deletions
62
Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Form1.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Form1.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,48 @@ | ||
using System; | ||
using Syncfusion.ExcelToPdfConverter; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.XlsIO; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace Convert_Excel_to_PDF | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
} | ||
private void btnConvert_Click(object sender, EventArgs e) | ||
{ | ||
//Create an instance of ExcelEngine | ||
using (ExcelEngine excelEngine = new ExcelEngine()) | ||
{ | ||
IApplication application = excelEngine.Excel; | ||
application.DefaultVersion = ExcelVersion.Xlsx; | ||
|
||
//Load an existing file | ||
FileStream excelStream = new FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); | ||
IWorkbook workbook = application.Workbooks.Open(excelStream); | ||
|
||
//Initialize ExcelToPdfConverter | ||
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); | ||
|
||
//Initialize PDF document | ||
PdfDocument pdfDocument = new PdfDocument(); | ||
|
||
//Convert Excel document into PDF document | ||
pdfDocument = converter.Convert(); | ||
|
||
//Save the converted PDF document to MemoryStream. | ||
pdfDocument.Save("Sample.pdf"); | ||
|
||
} | ||
//Launch the PDF file | ||
System.Diagnostics.Process.Start("Sample.pdf"); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/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,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace Convert_Excel_to_PDF | ||
{ | ||
internal static class Program | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
Application.EnableVisualStyles(); | ||
Application.SetCompatibleTextRenderingDefault(false); | ||
Application.Run(new Form1()); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...tarted/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Properties/AssemblyInfo.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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Convert-Excel-to-PDF")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Convert-Excel-to-PDF")] | ||
[assembly: AssemblyCopyright("Copyright © 2023")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("a97f8cb2-ec51-4f26-8484-5e6c9cef5371")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
71 changes: 71 additions & 0 deletions
71
.../Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Properties/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.