Convert Excel file to PDF, Word file. PDF file will be created by component or overwritten if already exist

Namespace:  SautinSoft
Assembly:  SautinSoft.XlsToPdf (in SautinSoft.XlsToPdf.dll) Version: 2.0.4.13

Syntax

      
 C#  Visual Basic 
public int ConvertFile(
	string xlsPath,
	string outPath
)
Public Function ConvertFile ( _
	xlsPath As String, _
	outPath As String _
) As Integer

Parameters

xlsPath
String
Path to Excel file
outPath
String
Path to output document

Return Value

0 - converting succesfully
1 - can't open input Excel file, check the input path
2 - can't create output file, check the output path
3 - converting failed

Examples

CopyHow to convert Excel file into PDF file in C#
using System;

namespace SampleConvert
{
    class Class1
    {
        static void Main(string[] args)
        {
            SautinSoft.XlsToPdf xtp = new SautinSoft.XlsToPdf();
            //this property is necessary only for registered version
            //xtp.Serial = "XXXXXXXXXXXXX";

            //specify some options
            xtp.PageStyle.PageOrientation.Landscape();
            //specify password for Excel workbook
            xtp.Password = "12345";
            //specify page numbers
            xtp.PageStyle.PageNumFormat = "Page {page} of {numpages}";

            string xlsFile = @"..\..\..\..\..\test.xls";
            string pdfFile = @"..\..\..\..\..\test.pdf";
            int result = xtp.ConvertFile(xlsFile, pdfFile);
            if (result == 0)
            {
                System.Console.WriteLine("Converted successfully!");
                System.Diagnostics.Process.Start(pdfFile);
            }
            else
                System.Console.WriteLine("Converting Error!");
        }

    }
}
CopyHow to convert Excel file into PDF file in VB.Net
Imports System.IO
Module Module1

    Sub Main()
        Dim xtp As New SautinSoft.XlsToPdf
        'this property is necessary only for registered version
        'xtp.Serial = "XXXXXXXXXXXXX";


        'specify some options
        xtp.PageStyle.PageOrientation.Landscape()
        'specify password for Excel workbook
        xtp.Password = "12345"
        'specify page numbers
        xtp.PageStyle.PageNumFormat = "Page {page} of {numpages}"

        Dim xlsFile As String = "..\..\..\..\test.xls"
        Dim pdfFile As String = "..\..\..\..\test.pdf"
        Dim result As Integer = xtp.ConvertFile(xlsFile, pdfFile)
        If result = 0 Then
            System.Console.WriteLine("Converted successfully!")
            System.Diagnostics.Process.Start(pdfFile)
        Else
            System.Console.WriteLine("Converting Error!")
        End If
    End Sub


End Module

See Also