Main class to export Excel spreadsheets in to PDF, Word. Allows to create an instance of converter object and call converting methods.

Namespace:  SautinSoft
Assembly:  SautinSoft.ExcelToPdf (in SautinSoft.ExcelToPdf.dll) Version: 4.0.2.29

Syntax

      
 C#  Visual Basic 
public class ExcelToPdf
Public Class ExcelToPdf

Members

            
 All Members  Constructors   Properties   Methods  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
ExcelToPdf()()()
Creates a new instance of ExcelToPdf class
ConvertBytes(array<Byte>[]()[])
Convert Excel bytes array to PDF, Word, RTF bytes array
ConvertByteToFile(array<Byte>[]()[], String)
Convert Excel bytes array to PDF, Word, RTF file. Output file will be created by component or overwritten if already exist
ConvertFile(String, String)
Convert Excel file to PDF, Word file. PDF file will be created by component or overwritten if already exist
ConvertFiletoBytes(String)
Convert Excel file to PDF, Word bytes array
CreateTraceFile
GetSheetsNumber(array<Byte>[]()[])
Returns numbers of sheets from Excel workbook
GetSheetsNumber(String)
Returns numbers of sheets from Excel workbook
MergePDFFileArrayToPDFFile(array<String>[]()[], String)
Merges different PDF files into single PDF file
MergePDFFileArrayToPDFStream(array<String>[]()[])
Merges different PDF files into single PDF
MergePDFFileToPDFFile(String, String)
Merges two PDF files. Merges File1Path and DestFile file into single DestFile.
MergePDFStreamArrayToPDFStream(ArrayList)
Merges different PDF documents into single PDF in memory
Options
Set up the info block properties for resulting documents, such as file version and document producer
OutputFormat
Specify format for output file: PDF, Word, RTF etc
PageStyle
Contains page properties for output PDF document: page size, orientation, page margins and put page numbers.
Password
A string which contains password for Excel workbook. It is necessary when you are converting password-protected Excel document.
Serial
A string which contains a serial number to activate your copy after purchasing. Use it when you got own serial number and registered version.
Sheets
Set custom sheets for converting. By default all sheets from workbook will be converted
SplitPDFFileToPDFFolder(String, String)
Splits PDF document by pages
TraceFilePath
UnicodeOptions
Allows to specify options to properly convert Unicode, such as "Fonts" directory etc

Remarks

Examples

CopyASP.Net - Export Excel to PDF in C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Result.Text = "";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile.FileName.Length == 0 || FileUpload1.FileBytes.Length==0)
        {
            Result.Text = "Please select an Excel document for conversion!";
            return;
        }        

        SautinSoft.ExcelToPdf x = new SautinSoft.ExcelToPdf();        
        x.PageStyle.PageSize.Letter();


        byte[] pdfBytes = null;

        try
        {
            pdfBytes = x.ConvertBytes(FileUpload1.FileBytes);
        }
        catch { }

        //show PDF
        if (pdfBytes != null)
        {
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = "application/PDF";
            Response.AppendHeader("content-disposition", "attachment; filename=Result.pdf");
            Response.BinaryWrite(pdfBytes);
            Response.Flush();
            Response.End();
        }
        else
        {
            Result.Text = "Converting failed!";
        }
    }
}
CopyASP.Net - Export Excel to PDF in VB.Net
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO

Partial Public Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Result.Text = ""
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        If FileUpload1.PostedFile.FileName.Length = 0 OrElse FileUpload1.FileBytes.Length=0 Then
            Result.Text = "Please select an Excel document for conversion!"
            Return
        End If
        Result.Text = "Converting ..."

        Dim x As New SautinSoft.ExcelToPdf()
        x.PageStyle.PageSize.Letter()


        Dim pdfBytes() As Byte = Nothing

        Try
            pdfBytes = x.ConvertBytes(FileUpload1.FileBytes)
        Catch

        End Try


        'show PDF
        If pdfBytes IsNot Nothing Then
            Response.Buffer = True
            Response.Clear()
            Response.ContentType = "application/PDF"
            Response.BinaryWrite(pdfBytes)
            Response.Flush()
            Response.End()
        Else
            Result.Text = "Converting failed!"
        End If
    End Sub
End Class

Inheritance Hierarchy

System..::.Object
  SautinSoft..::.ExcelToPdf

See Also