Convert Excel file to PDF, Word file. PDF file will be created by component or overwritten if already exist
Namespace:
SautinSoftAssembly: SautinSoft.XlsToPdf (in SautinSoft.XlsToPdf.dll) Version: 2.0.4.13
Syntax
| C# | Visual Basic |
Return Value
0 - converting succesfully1 - can't open input Excel file, check the input path
2 - can't create output file, check the output path
3 - converting failed
Examples
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!"); } } }
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