From 7d7fa8be51a34ca9256cb43183aeb4e3da1f32b4 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Tue, 11 Nov 2025 21:11:51 +0530 Subject: [PATCH 1/4] 988184-PageSetup --- .../NET/Excel-to-PDF-Conversion.md | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md index 869b8edea..21ee7f22c 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md @@ -1711,6 +1711,104 @@ Malgun Gothic, Batang +## Page Setup Options + +### Paper size + +The following code illustrates how to convert an Excel workbook to PDF by setting the paper size for all worksheets. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Excel%20to%20PDF/Page%20Setup%20Options/.NET/Paper%20Size/Paper%20Size/Program.cs,180" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); + + //Set the paper size to A4 for all worksheets + foreach (IWorksheet worksheet in workbook.Worksheets) + { + worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4; + } + + //Initialize XlsIORendererSettings + XlsIORendererSettings settings = new XlsIORendererSettings(); + + //Set the layout option as FitAllColumnsOnOnePage + settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; + + //Initialize XlsIORenderer + XlsIORenderer renderer = new XlsIORenderer(); + + //Convert the Excel document to PDF with renderer settings + PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings); + + //Save the workbook as PDF + pdfDocument.Save(Path.GetFullPath("Output/Output.pdf")); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); + + //Set the paper size to A4 for all worksheets + foreach (IWorksheet worksheet in workbook.Worksheets) + { + worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4; + } + + //Initialize ExcelToPdfConverterSettings + ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings(); + + //Set the layout option as FitAllColumnsOnOnePage + settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; + + //Load the Excel document into ExcelToPdfConverter + ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); + + //Convert the Excel document to PDF with converter settings + PdfDocument pdfDocument = converter.Convert(settings); + + //Save the PDF document + pdfDocument.Save("Output.pdf"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As ExcelEngine = New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") + + 'Set the paper size to A4 for all worksheets + For Each worksheet As IWorksheet In workbook.Worksheets + worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4 + Next + + 'Initialize ExcelToPdfConverterSettings + Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings() + + 'Set the layout option as FitAllColumnsOnOnePage + settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage + + 'Load the Excel document into ExcelToPdfConverter + Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook) + + 'Convert the Excel document to PDF with converter settings + Dim pdfDocument As PdfDocument = converter.Convert(settings) + + 'Save the workbook as PDF + pdfDocument.Save("Output.pdf") +End Using +{% endhighlight %} +{% endtabs %} + +A complete working example to convert an Excel workbook to PDF by setting the paper size for all worksheets in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20PDF/Page%20Setup%20Options/.NET/Paper%20Size). + ## Supported elements This feature supports the following elements: From ed38a22c206bebd9785dca90c165ba6e86e382fa Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Tue, 11 Nov 2025 22:06:09 +0530 Subject: [PATCH 2/4] 988184-PageSetup --- .../Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md index 21ee7f22c..49be8838f 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md @@ -1807,7 +1807,7 @@ End Using {% endhighlight %} {% endtabs %} -A complete working example to convert an Excel workbook to PDF by setting the paper size for all worksheets in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20PDF/Page%20Setup%20Options/.NET/Paper%20Size). +A complete working example to convert an Excel workbook to PDF by setting the paper size for all worksheets in C# is present on this GitHub page. ## Supported elements From 54f4a04600d179d43c12ef16f76094e455ae0187 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Tue, 11 Nov 2025 22:58:33 +0530 Subject: [PATCH 3/4] 988184-PageSetup --- .../NET/Excel-to-PDF-Conversion.md | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md index 49be8838f..435b63c6a 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md @@ -1809,6 +1809,102 @@ End Using A complete working example to convert an Excel workbook to PDF by setting the paper size for all worksheets in C# is present on this GitHub page. +### Orientation + +The following code illustrates how to convert an Excel workbook to PDF by setting the page orientation. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Excel%20to%20PDF/Page%20Setup%20Options/.NET/Orientation/Orientation/Program.cs,180" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); + + //Set the page orientation for all worksheets + foreach (IWorksheet worksheet in workbook.Worksheets) + { + worksheet.PageSetup.Orientation = ExcelPageOrientation.Portrait; + } + + //Initialize XlsIORendererSettings + XlsIORendererSettings settings = new XlsIORendererSettings(); + + //Set the layout option as FitAllColumnsOnOnePage + settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; + + //Initialize XlsIORenderer + XlsIORenderer renderer = new XlsIORenderer(); + + //Convert the Excel document to PDF with renderer settings + PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings); + + //Save the workbook as PDF + pdfDocument.Save(Path.GetFullPath("Output/Output.pdf")); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); + + //Set the page orientation for all worksheets + foreach (IWorksheet worksheet in workbook.Worksheets) + { + worksheet.PageSetup.Orientation = ExcelPageOrientation.Portrait; + } + + //Initialize ExcelToPdfConverterSettings + ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings(); + + //Set the layout option as FitAllColumnsOnOnePage + settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; + + //Load the Excel document into ExcelToPdfConverter + ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); + + //Convert the Excel document to PDF with converter settings + PdfDocument pdfDocument = converter.Convert(settings); + + //Save the PDF document + pdfDocument.Save("Output.pdf"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As ExcelEngine = New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") + + 'Set the page orientation for all worksheets + For Each worksheet As IWorksheet In workbook.Worksheets + worksheet.PageSetup.Orientation = ExcelPageOrientation.Portrait + Next + + 'Initialize ExcelToPdfConverterSettings + Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings() + + 'Set the layout option as FitAllColumnsOnOnePage + settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage + + 'Load the Excel document into ExcelToPdfConverter + Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook) + + 'Convert the Excel document to PDF with converter settings + Dim pdfDocument As PdfDocument = converter.Convert(settings) + + 'Save the workbook as PDF + pdfDocument.Save("Output.pdf") +End Using +{% endhighlight %} +{% endtabs %} + +A complete working example to convert an Excel workbook to PDF by setting the page orientation in C# is present on this GitHub page. + ## Supported elements This feature supports the following elements: From ff59f235dc3ead7e5f4ed846bc6ff635e16fd927 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Tue, 18 Nov 2025 14:53:56 +0530 Subject: [PATCH 4/4] 988184-PageSetup --- .../NET/Excel-to-PDF-Conversion.md | 194 ------------------ .../NET/Worksheet/Page-Setup-Options.md | 116 ++++++++++- 2 files changed, 115 insertions(+), 195 deletions(-) diff --git a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md index 435b63c6a..869b8edea 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-PDF/NET/Excel-to-PDF-Conversion.md @@ -1711,200 +1711,6 @@ Malgun Gothic, Batang -## Page Setup Options - -### Paper size - -The following code illustrates how to convert an Excel workbook to PDF by setting the paper size for all worksheets. - -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Excel%20to%20PDF/Page%20Setup%20Options/.NET/Paper%20Size/Paper%20Size/Program.cs,180" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); - - //Set the paper size to A4 for all worksheets - foreach (IWorksheet worksheet in workbook.Worksheets) - { - worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4; - } - - //Initialize XlsIORendererSettings - XlsIORendererSettings settings = new XlsIORendererSettings(); - - //Set the layout option as FitAllColumnsOnOnePage - settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; - - //Initialize XlsIORenderer - XlsIORenderer renderer = new XlsIORenderer(); - - //Convert the Excel document to PDF with renderer settings - PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings); - - //Save the workbook as PDF - pdfDocument.Save(Path.GetFullPath("Output/Output.pdf")); -} -{% endhighlight %} - -{% highlight c# tabtitle="C# [Windows-specific]" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); - - //Set the paper size to A4 for all worksheets - foreach (IWorksheet worksheet in workbook.Worksheets) - { - worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4; - } - - //Initialize ExcelToPdfConverterSettings - ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings(); - - //Set the layout option as FitAllColumnsOnOnePage - settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; - - //Load the Excel document into ExcelToPdfConverter - ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); - - //Convert the Excel document to PDF with converter settings - PdfDocument pdfDocument = converter.Convert(settings); - - //Save the PDF document - pdfDocument.Save("Output.pdf"); -} -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() - Dim application As IApplication = excelEngine.Excel - application.DefaultVersion = ExcelVersion.Xlsx - Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") - - 'Set the paper size to A4 for all worksheets - For Each worksheet As IWorksheet In workbook.Worksheets - worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4 - Next - - 'Initialize ExcelToPdfConverterSettings - Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings() - - 'Set the layout option as FitAllColumnsOnOnePage - settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage - - 'Load the Excel document into ExcelToPdfConverter - Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook) - - 'Convert the Excel document to PDF with converter settings - Dim pdfDocument As PdfDocument = converter.Convert(settings) - - 'Save the workbook as PDF - pdfDocument.Save("Output.pdf") -End Using -{% endhighlight %} -{% endtabs %} - -A complete working example to convert an Excel workbook to PDF by setting the paper size for all worksheets in C# is present on this GitHub page. - -### Orientation - -The following code illustrates how to convert an Excel workbook to PDF by setting the page orientation. - -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Excel%20to%20PDF/Page%20Setup%20Options/.NET/Orientation/Orientation/Program.cs,180" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); - - //Set the page orientation for all worksheets - foreach (IWorksheet worksheet in workbook.Worksheets) - { - worksheet.PageSetup.Orientation = ExcelPageOrientation.Portrait; - } - - //Initialize XlsIORendererSettings - XlsIORendererSettings settings = new XlsIORendererSettings(); - - //Set the layout option as FitAllColumnsOnOnePage - settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; - - //Initialize XlsIORenderer - XlsIORenderer renderer = new XlsIORenderer(); - - //Convert the Excel document to PDF with renderer settings - PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings); - - //Save the workbook as PDF - pdfDocument.Save(Path.GetFullPath("Output/Output.pdf")); -} -{% endhighlight %} - -{% highlight c# tabtitle="C# [Windows-specific]" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); - - //Set the page orientation for all worksheets - foreach (IWorksheet worksheet in workbook.Worksheets) - { - worksheet.PageSetup.Orientation = ExcelPageOrientation.Portrait; - } - - //Initialize ExcelToPdfConverterSettings - ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings(); - - //Set the layout option as FitAllColumnsOnOnePage - settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage; - - //Load the Excel document into ExcelToPdfConverter - ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); - - //Convert the Excel document to PDF with converter settings - PdfDocument pdfDocument = converter.Convert(settings); - - //Save the PDF document - pdfDocument.Save("Output.pdf"); -} -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() - Dim application As IApplication = excelEngine.Excel - application.DefaultVersion = ExcelVersion.Xlsx - Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") - - 'Set the page orientation for all worksheets - For Each worksheet As IWorksheet In workbook.Worksheets - worksheet.PageSetup.Orientation = ExcelPageOrientation.Portrait - Next - - 'Initialize ExcelToPdfConverterSettings - Dim settings As ExcelToPdfConverterSettings = New ExcelToPdfConverterSettings() - - 'Set the layout option as FitAllColumnsOnOnePage - settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage - - 'Load the Excel document into ExcelToPdfConverter - Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook) - - 'Convert the Excel document to PDF with converter settings - Dim pdfDocument As PdfDocument = converter.Convert(settings) - - 'Save the workbook as PDF - pdfDocument.Save("Output.pdf") -End Using -{% endhighlight %} -{% endtabs %} - -A complete working example to convert an Excel workbook to PDF by setting the page orientation in C# is present on this GitHub page. - ## Supported elements This feature supports the following elements: diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md index 947905787..66a89a2ca 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md @@ -1024,4 +1024,118 @@ End Using {% endhighlight %} {% endtabs %} -A complete working example to add headers and footers in an Excel document using C# is present on [this GitHub page.](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Worksheet%20Features/Header%20and%20Footer/.NET/Header%20and%20Footer) \ No newline at end of file +A complete working example to add headers and footers in an Excel document using C# is present on [this GitHub page.](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Worksheet%20Features/Header%20and%20Footer/.NET/Header%20and%20Footer) + +## Paper Size + +The PaperSize functionality allows you to specify the paper size for worksheet. + +The following code snippet shows how to use PaperSize. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Worksheet%20Features/PaperSize/.NET/PaperSize/PaperSize/Program.cs,180" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set the paper size to A4 + worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4; + + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set the paper size to A4 + worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4; + + //Saving the workbook + workbook.SaveAs("Output.xlsx"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As ExcelEngine = New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + 'Set the paper size to A4 + worksheet.PageSetup.PaperSize = ExcelPaperSize.PaperA4 + + 'Saving the workbook + workbook.SaveAs("Output.xlsx") +End Using +{% endhighlight %} +{% endtabs %} + +A complete working example to set the paper size in C# is present on this GitHub page. + +## Orientation + +The Orientation functionality allows you to specify the orientation for worksheet. + +The following code snippet shows how to use Orientation. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Worksheet%20Features/Orientation/.NET/Orientation/Orientation/Program.cs,180" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set the page orientation + worksheet.PageSetup.Orientation = ExcelPageOrientation.Landscape; + + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set the page orientation + worksheet.PageSetup.Orientation = ExcelPageOrientation.Landscape; + + //Saving the workbook + workbook.SaveAs("Output.xlsx"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As ExcelEngine = New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + 'Set the page orientation + worksheet.PageSetup.Orientation = ExcelPageOrientation.Landscape + + 'Saving the workbook + workbook.SaveAs("Output.xlsx") +End Using +{% endhighlight %} +{% endtabs %} + +A complete working example to set the page orientation in C# is present on this GitHub page. \ No newline at end of file