Skip to content

Commit 7e27361

Browse files
988184-Orientation
1 parent ae1cc7f commit 7e27361

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-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.36221.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orientation", "Orientation\Orientation.csproj", "{73CEE7DC-9419-4D38-835E-10FDEE4F9777}"
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+
{73CEE7DC-9419-4D38-835E-10FDEE4F9777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{73CEE7DC-9419-4D38-835E-10FDEE4F9777}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{73CEE7DC-9419-4D38-835E-10FDEE4F9777}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{73CEE7DC-9419-4D38-835E-10FDEE4F9777}.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 = {01823986-E93C-4E99-B0D6-18D6776118A9}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.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="Data\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
<None Update="Output\*">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>

Excel to PDF/Page Setup Options/.NET/Orientation/Orientation/Output/.gitkeep

Whitespace-only changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.IO;
2+
using Syncfusion.XlsIO;
3+
using Syncfusion.Pdf;
4+
using Syncfusion.XlsIORenderer;
5+
6+
namespace Orientation
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
using (ExcelEngine excelEngine = new ExcelEngine())
13+
{
14+
IApplication application = excelEngine.Excel;
15+
application.DefaultVersion = ExcelVersion.Xlsx;
16+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"../../../Data/InputTemplate.xlsx"));
17+
18+
//Set the page orientation for all worksheets
19+
foreach (IWorksheet worksheet in workbook.Worksheets)
20+
{
21+
worksheet.PageSetup.Orientation = ExcelPageOrientation.Portrait;
22+
}
23+
24+
//Initialize XlsIORendererSettings
25+
XlsIORendererSettings settings = new XlsIORendererSettings();
26+
27+
//Set the layout option as FitAllColumnsOnOnePage
28+
settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;
29+
30+
//Initialize XlsIORenderer
31+
XlsIORenderer renderer = new XlsIORenderer();
32+
33+
//Convert the Excel document to PDF with renderer settings
34+
PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings);
35+
36+
//Save the workbook as PDF
37+
pdfDocument.Save(Path.GetFullPath("../../../Output/Output.pdf"));
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)