Click or drag to resize

ExcelToPdf Class

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

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

The ExcelToPdf type exposes the following members.

Public methodCode exampleExcelToPdf Creates a new instance of ExcelToPdf class
Public propertyCode exampleCreateTraceFile Gets or sets whether to create a trace file. Default value: false.
Public propertyOptions Set up the info block properties for resulting documents, such as file version and a document producer.
Public propertyCode exampleOutputFormat Specify format for output file: PDF, Word, RTF etc. Default value: Pdf.
Public propertyPageStyle Contains page properties for output PDF document: page size, orientation, page margins and put page numbers.
Public propertyCode exampleSerial A string which contains a serial number to activate your copy after purchasing. Use it when you got own serial number and registered version.
Public propertyCode exampleSheets Set custom sheets for converting. By default all sheets from workbook will be converted.
Public propertyTraceFilePath Path to create a tracing file. Allows to track issues and exceptions which appeared during the conversion cycle. Default value: "C:\trace.txt"
Public propertyUnicodeOptions Allows to specify options to properly convert Unicode, such as "Fonts" directory etc
Public methodCode exampleConvertBytes Convert Excel bytes array to PDF, Word, RTF bytes array
Public methodConvertByteToFile Convert Excel bytes array to PDF, Word, RTF file. Output file will be created by component or overwritten if already exist
Public methodCode exampleConvertFile Convert Excel file to PDF, Word file. PDF file will be created by component or overwritten if already exist
Public methodConvertFiletoBytes Convert Excel file to PDF, Word bytes array
Public methodEquals
(Inherited from Object)
Public methodGetHashCode
(Inherited from Object)
Public methodCode exampleGetSheetsNumber(Byte) Returns numbers of sheets from Excel workbook
Public methodCode exampleGetSheetsNumber(String) Returns numbers of sheets from Excel workbook
Public methodGetType
(Inherited from Object)
Public methodCode exampleMergePDFFileArrayToPDFFile Merges different PDF files into single PDF file
Public methodMergePDFFileArrayToPDFStream Merges different PDF files into single PDF
Public methodMergePDFFileToPDFFile Merges two PDF files. Merges File1Path and DestFile file into single DestFile.
Public methodMergePDFStreamArrayToPDFStream Merges different PDF documents into single PDF in memory
Public methodCode exampleSplitPDFFileToPDFFolder Splits PDF document by pages
Public methodToString
(Inherited from Object)
ASP.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!";

        SautinSoft.ExcelToPdf x = new SautinSoft.ExcelToPdf();        

        byte[] pdfBytes = null;

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

        //show PDF
        if (pdfBytes != null)
            Response.Buffer = true;
            Response.ContentType = "application/PDF";
            Response.AppendHeader("content-disposition", "attachment; filename=Result.pdf");
            Result.Text = "Converting failed!";
ASP.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!"
        End If
        Result.Text = "Converting ..."

        Dim x As New SautinSoft.ExcelToPdf()

        Dim pdfBytes() As Byte = Nothing

            pdfBytes = x.ConvertBytes(FileUpload1.FileBytes)

        End Try

        'show PDF
        If pdfBytes IsNot Nothing Then
            Response.Buffer = True
            Response.ContentType = "application/PDF"
            Result.Text = "Converting failed!"
        End If
    End Sub
End Class
See Also