Click or drag to resize

ExcelToPdfCSheetPrintedArea Class

Allows to specify which custom sheets and cells will be exported into PDF, Word
Inheritance Hierarchy
SystemObject
  SautinSoftExcelToPdfCSheetPrintedArea

Namespace: SautinSoft
Assembly: SautinSoft.ExcelToPdf (in SautinSoft.ExcelToPdf.dll) Version: 2023.11.22
Syntax
public class PrintedArea

The ExcelToPdfCSheetPrintedArea type exposes the following members.

Constructors
 NameDescription
Public methodExcelToPdfCSheetPrintedArea Creates a new instance of ExcelToPdfCSheetPrintedArea class
Top
Methods
 NameDescription
Public methodCode exampleAdd(String, String, Int32) Adds custom area to export in PDF, Word
Public methodCode exampleAdd(Int32, Int32, Int32, Int32, Int32) Adds custom area to export in PDF, Word by column and row numbers.
Public methodClear Mark all sheets and cells in workbook to export into PDF, Word
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Example
Export to PDF only custom area from sheet in C#
using System;
using System.IO;
using SautinSoft;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            // Set custom area to convert.
            ExcelToPdf x = new ExcelToPdf();
            x.PageStyle.PageSize.Letter();

            // Set PDF as output format.
            x.OutputFormat = SautinSoft.ExcelToPdf.eOutputFormat.Pdf;

            // Let's convert only rectangle from "B6" to "C9" on sheet 1.            
            x.Sheets.PrintArea.Add("B6", "C9", new int[]{1});

            string excelFile = Path.GetFullPath(@"..\..\..\test.xlsx");
            string pdfFile = Path.ChangeExtension(excelFile, ".pdf"); ;

            try
            {
                x.ConvertFile(excelFile, pdfFile);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfFile) { UseShellExecute = true });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
    }
}
Export to PDF only custom area from sheet in VB.Net
Imports System
Imports System.IO
Imports SautinSoft

Module Sample

    Sub Main()
        ' Set custom area to convert.
        Dim x As New ExcelToPdf()
        x.PageStyle.PageSize.Letter()

        ' Set PDF as output format.
        x.OutputFormat = SautinSoft.ExcelToPdf.eOutputFormat.Pdf

        ' Let's convert only rectangle from "B6" to "C9" on sheet 1.            
        x.Sheets.PrintArea.Add("B6", "C9", New Integer() {1})

        Dim excelFile As String = Path.GetFullPath("..\..\..\test.xlsx")
        Dim pdfFile As String = Path.ChangeExtension(excelFile, ".pdf")

        Try
            x.ConvertFile(excelFile, pdfFile)
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pdfFile) With {.UseShellExecute = True})
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Console.ReadLine()
        End Try
    End Sub
End Module
See Also