Skip to content

Commit 71b4c42

Browse files
authored
Merge pull request #268 from SyncfusionExamples/988184-PaperSizeSample
988184 - Specify the paper size and orientation in Excel to PDF conversion
2 parents 716abc7 + d00eddd commit 71b4c42

File tree

10 files changed

+102
-0
lines changed

10 files changed

+102
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Orientation/Orientation.csproj" />
3+
</Solution>
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>net10.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Output\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
<None Update="Data\*">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>

Worksheet Features/Orientation/.NET/Orientation/Orientation/Output/.gitkeep

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.IO;
2+
using Syncfusion.XlsIO;
3+
4+
namespace Orientation
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
using (ExcelEngine excelEngine = new ExcelEngine())
11+
{
12+
IApplication application = excelEngine.Excel;
13+
application.DefaultVersion = ExcelVersion.Xlsx;
14+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
15+
IWorksheet worksheet = workbook.Worksheets[0];
16+
17+
//Set the page orientation
18+
worksheet.PageSetup.Orientation = ExcelPageOrientation.Landscape;
19+
20+
//Saving the workbook
21+
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
22+
}
23+
}
24+
}
25+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="PaperSize/PaperSize.csproj" />
3+
</Solution>
Binary file not shown.

Worksheet Features/PaperSize/.NET/PaperSize/PaperSize/Output/.gitkeep

Whitespace-only changes.
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>net10.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Output\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
<None Update="Data\*">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.IO;
2+
using Syncfusion.XlsIO;
3+
4+
namespace PaperSize
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
using (ExcelEngine excelEngine = new ExcelEngine())
11+
{
12+
IApplication application = excelEngine.Excel;
13+
application.DefaultVersion = ExcelVersion.Xlsx;
14+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
15+
IWorksheet worksheet = workbook.Worksheets[0];
16+
17+
//Set the paper size to A4
18+
worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4;
19+
20+
//Saving the workbook
21+
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)