Spire.DataExport supports exporting data from DataTable into HTML. HTML (HyperText Markup Language) is a language for describing web pages. HTML documents are also called web pages which contain HTML tags and plain text. Use Spire.DataExport exporting DataTable to HTML to share your data on internet.

Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to HTML exporting process.

Step 1: Load Data Information

Before exporting data from DataTable, we should load data information from data source. And select which information we need export. Through DataGridVew, we even can preview and modify data information. So, in this step, our job is to prepare data which are about to be exported out.

[C#]
	
        private void btnLoad_Click(object sender, EventArgs e)
        {
            using (OleDbConnection oleDbConnection = new OleDbConnection())
            {
                oleDbConnection.ConnectionString = this.tbCS.Text;
                System.Data.OleDb.OleDbCommand oleDbCommand = new OleDbCommand();
                oleDbCommand.CommandText = this.tbCT.Text;
                oleDbCommand.Connection = oleDbConnection;
                using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
                {
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
            }
        }
   

Effect Screenshot

DataTable to HTML

Step 2: Set Export into HTML

Spire.DataExport allows user to export data into most popular file formats including MS Excel, MS Word, HTML, PDF, XML, CSV, DBF, DIF, etc. Here we need set it as HTML format. Spire.DataExport will create a new HTML file and through DataGridView export data into HTML file. You also can rename the file as you like.

[C#]
        private void btnRun_Click(object sender, EventArgs e)
        {
            Spire.DataExport.HTML.HTMLExport HTMLExport = new Spire.DataExport.HTML.HTMLExport();
            HTMLExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
            HTMLExport.DataTable = this.dataGridView1.DataSource as DataTable;
            HTMLExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
            HTMLExport.SaveToFile("20110223.html");
        }  

Effect Screenshot

DataTable to HTML

Monday, 18 July 2011 05:40

How to Convert Word to RTF

Why Convert Word to RTF?

Since 1990s, Microsoft began to use .doc extension for a range of their proprietary word processing formats. Doc format is usually associated with Microsoft Office applications. But storing text in Doc files is not always convenient, as they are not compatible with the majority of third-party text editors. To make Doc information more accessible, it is better to store it in other, more common format. And as a rule, users select RTF format, because it is supported by the wide range of applications.

How to Convert Word to RTF with Spire.Doc?

Spire.Doc can convert Word to RTF without Microsoft Office installed on your system. Download Spire.Doc (or Spire.Office) with .NET Framework 2.0 (or above) and follow the simple steps below to convert Word to RTF.

Step 1: Create a project through Visual Studio and add Spire.Doc DLL as reference.

Step 2: Load local Word doc file which we need to convert to RTF format. Use the code below to load Word file.

            Document document = new Document();
            document.LoadFromFile(@"D:\Sample.doc");

Step 3: Spire.Doc allows users to convert Word doc files to most of popular file formats including PDF, HTML, RTF, EPub, XML, Dot, Text, etc. The following code can help us convert Word to RTF.

document.SaveToFile("Sample.rtf", FileFormat.Rtf);

Step 4: Copy the full code below into the project and start the project by pressing F5.

Full Code:

[C#]
	private void button1_Click(object sender, EventArgs e)
	{
	    //Create word document
	    Document document = new Document();
	    document.LoadFromFile(@"D:\Sample.doc");

	    //Save doc file.
	    document.SaveToFile("Sample.rtf", FileFormat.Rtf);

	    //Launching the MS Word file.
	    WordDocViewer("Sample.rtf");
	}

	private void WordDocViewer(string fileName)
	{
	    try
	    {
	        System.Diagnostics.Process.Start(fileName);
	    }
	    catch { }
	}
   
[VB.NET]
	Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
	    'Create word document
	    Dim document_Renamed As New Document()
	    document_Renamed.LoadFromFile("D:\Sample.doc")

	    'Save doc file.
	    document_Renamed.SaveToFile("Sample.rtf", FileFormat.Rtf)

	    'Launching the MS Word file.
	    WordDocViewer("Sample.rtf")
	End Sub

	Private Sub WordDocViewer(ByVal fileName As String)
	    Try
	        Process.Start(fileName)
	    Catch
	    End Try
	End Sub        

Effective Screenshot:

Word to RTF

Friday, 15 July 2011 06:36

How to Convert XML to Word

Why Use C#/VB.NET Convert Office OpenXML to Word?

As a great programming language, Office OpenXML is hard to navigate and access when in its natural form. And converting files from Office OpenXML to Word form can help to find and alter parts of code. On the other hand, converting Office OpenXML to Word is helpful in sharing the code with others.

How to Use C#/VB.NET Convert Office OpenXML to Word?

Spire.Doc allows users to convert files from Office OpenXML to Word with C#/VB.NET. Spire.Doc is a MS Word component which enables user to perform a wide range of Word document processing tasks directly for .NET and Silverlight. Like Microsoft Word can help you save Word files to different format, Spire.Doc also support converting files from Word to HTML, PDF, Office OpenXML, RTF, Text, Docx, Dot, etc. Furthermore, besides converting files from Word to other popular file format, Spire.Doc can also transfer files from Office OpenXML to Word, RTF to Word, Text to Word, Dot to Word, etc.

Download Spire.Doc (or Spire.Office) with .NET framework together and use the C#/VB.NET code below to convert Office OpenXML to Word.

[C#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Doc;

namespace Xml2Word
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile("sample.xml", FileFormat.Xml);
            doc.SaveToFile("test.doc", FileFormat.Doc);
        }
    }
}
[VB.NET]
Imports System.Text
Imports Spire.Doc

Namespace Xml2Word
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			Dim doc As New Document()
			doc.LoadFromFile("sample.xml", FileFormat.Xml)
			doc.SaveToFile("test.doc", FileFormat.Doc)
		End Sub
	End Class
End Namespace
Friday, 15 July 2011 05:49

How to Convert HTML to Word

Why Use C#/VB.NET to Convert HTML to Word?

Save HTML file content into Word document can be very easy only through copy and paste. Or users can right click on the html document and then choose edit. It automatically opens in Word. Then you can save it as a Word .doc file. But first, “Copy and paste” method can only used on text-only pages or some very basic HTML pages. For complex HTML, it may happen to formatting is not rendered properly, images are placed incorrectly, sometimes even missing, and CSS layout seems to be ignored completely. Second, edit on HTML document also will lead CSS ignored. But with C#/VB.NET, save files from HTML to Word could be much better. Furthermore, it doesn’t need Microsoft Office installed on your system.

How to Use C#/VB.NET to Convert HTML to Word?

With a .NET library, we can use C#/VB.NET convert HTML to Word effortlessly. Spire.Doc is a MS Word component which enables user to perform a wide range of Word document processing tasks directly for .NET and Silverlight. Like Microsoft Word can help you save Word files to different format, Spire.Doc also support converting files from Word Doc to HTML, PDF, XML, RTF, Text, Docx, Dot, etc. Furthermore, besides converting files from Word to other popular file format, Spire.Doc can also transfer files from HTML to Doc, XML to Doc, RTF to Doc, Text to Doc, Docx to Doc, Dot to Doc, etc.

Download Spire.Doc (or Spire.Office) with .NET framework together and follow the simple steps below to convert HTML to Word.

Step 1: Create a project in Visual Studio and add Spire.Doc as reference.

Step 2: Load the HTML file which will be converted to Word doc file by using the follow code:

            Document document = new Document();
            document.LoadFromFile(@"D:\Work\Stephen\2011.12.06\test.html",FileFormat.Html,XHTMLValidationType.None);

Step 3: The following code below can help us convert the HTML file to Word doc. Furthermore, Spire.Doc also enables convert HTML to PDF, XML, ePub, Text, Dot, etc.

document.SaveToFile("test.doc", FileFormat.Doc);

Step 4: Write the whole simple code into the project and press F5 to start the conversion.

Full code:

[C#]
using System;
using Spire.Doc;
using Spire.Doc.Documents;

namespace Html2Doc
{
    class Program
    {
        static void Main(string[] args)
        {
            Document document = new Document();
            document.LoadFromFile(@"D:\test.html",FileFormat.Html,XHTMLValidationType.None);
            document.SaveToFile("test.doc", FileFormat.Doc);
        }
    }
}
[VB.NET]
Imports System
Imports Spire.Doc
Imports Spire.Doc.Documents

Namespace Html2Doc
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			Dim document As New Document()
			document.LoadFromFile("D:\test.html",FileFormat.Html,XHTMLValidationType.None)
			document.SaveToFile("test.doc", FileFormat.Doc)
		End Sub
	End Class
End Namespace

The output Word doc file can be find in Bin folder

HTML to Word

Effective Screeshot:

HTML to Word

Thursday, 14 July 2011 06:14

Convert Word to HTML in C#, VB.NET

Word to html conversion enables programmers and developers to create html through editing and degining word. Finally convert word to html. This section will introduce a solution to convert word to html via a .NET Word component with C#, VB.NET.

Spire.Doc for .NET, a professional word component, without installing MS Word, enables you to convert word to html with two lines of key code. One is Document.LoadFromFile(string fileName) method which is used to load your word file from system. The other is Document.SaveToFile(string fileName, FileFormat fileFormat) that is responsible to save word as html file.

Here you can view the effect of word to html conversion task. Please feel free to download Spire.Doc for .NET and view the detail code after the picture above.

Word to HTML

[C#]
using Spire.Doc;
using Spire.Doc.Documents;

namespace Word_to_HTML
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Create word document
            Document document = new Document();
            document.LoadFromFile(@"..\wordtohtml.doc");

            //Save doc file to html
            document.SaveToFile("toHTML.html", FileFormat.Html);
            WordDocViewer("toHTML.html");
        }

        private void WordDocViewer(string fileName)
        {
            try
            {
                System.Diagnostics.Process.Start(fileName);
            }
            catch { }
        }
    }
}

[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents

Namespace Word_to_HTML
    
    Public Class Form1
        Inherits Form
        
        Public Sub New()
            MyBase.New
            InitializeComponent
        End Sub
        
        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            'Create word document
            Dim document As Document = New Document
            document.LoadFromFile("..\wordtohtml.doc")
            'Save doc file to html
            document.SaveToFile("toHTML.html", FileFormat.Html)
            WordDocViewer("toHTML.html")
        End Sub
        
        Private Sub WordDocViewer(ByVal fileName As String)
            Try 
                System.Diagnostics.Process.Start(fileName)
            Catch  As System.Exception
                
            End Try
        End Sub
    End Class
End Namespace

Spire.Doc is a Microsoft Word component, which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF, .NET and Silverlight.

Wednesday, 13 July 2011 06:07

How to Convert Word to Text

Why We Convert Word to Text?

Text is a format usually contains plain text or with minimum formatting. We can get benefits from Word to Text conversion:

  • Much smaller file size to save disk space
  • Compatible with almost all applications
  • Without or with minimum formatting and/or unusual characters

How to Convert Word to Text?

Spire.Doc is a MS Word component which enables user to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document for .NET and Silverlight. It supports converting files from Word Doc to Text, HTML, PDF, XML, RTF, Docx, Dot, etc.

Download Spire.Doc (or Spire.Office) with .NET Framework 2.0 (or above) together and follow the simple code below to convert Word to Text.

Step 1: Create a project in Visual Studio. Add Spire.Doc DLL as reference.

Step 2: Use the following code to load local Word docfile which you want to convert to Txt file.

            Document document = new Document();
            document.LoadFromFile(@"D:\Work\Stephen\2011.12.05\Sample.doc");

Step 3: Save the word doc file as HTML by using the code below:

            document.SaveToFile("Sample.txt", FileFormat.Txt);

Step 4: Write the following full code into your project and press F5 to start it. Then, a Txt file will be automatically generated.

[C#]
using System;
using System.Windows.Forms;
using Spire.Doc;
using Spire.Doc.Documents;

namespace tohtml_3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Create word document
            Document document = new Document();
            document.LoadFromFile(@"D:\Work\Stephen\2011.12.05\Sample.doc");

            //Save doc file.
            document.SaveToFile("Sample.txt", FileFormat.Txt);

            //Launching the MS Word file.
            WordDocViewer("Sample.txt");
        }

        private void WordDocViewer(string fileName)
        {
            try
            {
                System.Diagnostics.Process.Start(fileName);
            }
            catch { }
        }

    }
}
[VB.NET]
Imports System
Imports System.Windows.Forms
Imports Spire.Doc
Imports Spire.Doc.Documents

Namespace tohtml_3
	Partial Public Class Form1
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
			'Create word document
			Dim document As New Document()
			document.LoadFromFile("D:\Work\Stephen\2011.12.05\Sample.doc")

			'Save doc file.
			document.SaveToFile("Sample.txt", FileFormat.Txt)

			'Launching the MS Word file.
			WordDocViewer("Sample.txt")
		End Sub

		Private Sub WordDocViewer(ByVal fileName As String)
			Try
				System.Diagnostics.Process.Start(fileName)
			Catch
			End Try
		End Sub

	End Class
End Namespace

Effective Screenshot:

Word to Text

Wednesday, 13 July 2011 05:45

Generate Excel Charts in C#, VB.NET

Why Generate Excel Chart?

In Microsoft Excel, we can generate different charts based on our data information. These excel charts can easily relay your messages that may otherwise go unnoticed by your audience. Most excel charts can help international audiences to understand because they are universally known and easily explained. On the other hand, it’s very easy to generate excel charts.

How to Use .NET to Generate Excel Chart?

With Microsoft Excel, users can generate Excel charts including Pie Chart, Column Chart, Bar Chart, Line Chart, Radar Chart, etc. And with Spire.XLS for .NET, users can use .NET generate those charts either. Spire.XLS for .NET is .NET Excel component which enables your .NET applications to fast generate, read, write and modify Excel document without Microsoft Office Excel Automation.

Suppose we are generating an excel pie chart. Spire.XLS presents you an easy way to create a pie chart in the Excel workbook. First, you should create a pie chart with the sheet.Charts.Add method. You may control the resource of the data and title of the chart by setting DataRange and ChartTitle properties. What's more, we create an object to operate more about the chart. You may set the label and value of the pie with the properties cs.CategoryLabels and cs.Values. If you want to hide the value of the pie, you may set the cs.DataPoints.DefaultDataPoint.DataLabels.HasValue property false. In this demo, in order to reflect the effect of the chart, we set the grid lines of the worksheet invisible by assigning the sheet.GridLinesVisible false.

After running the demo, you may find a pie appear in the document:

Generate Excel Charts

Spire.XLS allows users use .NET generate excel charts including Pie Chart, Column Chart, bar chart, line chart, radar chart, Cone chart, Cylinder chart, Doughnut chart, pyramid chart, scatter chart, stock chart and surface chart.

Effective Screenshots

Spire.XLS use .NET Generate Bar Chart

Generate Excel Charts

Spire.XLS use .NET Generate Column Chart

Generate Excel Charts

Spire.XLS use .NET Generate Line Chart

Generate Excel Charts

Spire.XLS use .NET Generate Radar Chart

Generate Excel Charts

Monday, 11 July 2011 06:26

Convert Image to PDF in C#, VB.NET

When it comes to the conversion of image to PDF, people are commonly bothered by various problems such as: hardly load images to PDF files from streams or files on disk directly; some special image formats are neither supported by your tools nor clearly shown when they are converted to PDF. However, all these are not conversion problems at all for Spire.PDF users.

Spire.PDF, as a PDF component allows its users to not only to convert images of commonly used formats to PDF document such as jpg, bmp, png, but also to convert gif, tif and ico images to PDF, which can be the most special feature during the conversion task of image to PDF. Besides, Spire.PDF supports to load images from stream and files on disk. These distinct characters, not have the slightest doubt, provides great convenience for developers.

Below shows the effect of converting image to PDF via Spire.PDF through a screenshot.

Image to PDF

Apart from helping you accomplish your image to PDF conversion task in a quick and fast way via C#, VB.NET, Spire.PDF also can Extract text and images from PDF files. That is to say, you never worry about where your images located, you can load them to PDF as well as extract from PDF. Please Download Spire.PDF before you start your work. Below steps are for you to convert your image to PDF with clear effect. The screenshot is displayed after the procedure.

Step1: Use C#/VB.NET to create a PDF document

In this step, you need to create a new PDF file first, then, add a section in the newly built PDF, at last, add a page in the section that you just added.

[C#]
// Create a pdf document with a section and page added.
 PdfDocument doc = new PdfDocument();
 PdfSection section = doc.Sections.Add();
 PdfPageBase page = doc.Pages.Add();

[VB.NET]
 ' Create a pdf document with a section and page added.
 Dim doc As New PdfDocument()
 Dim section As PdfSection = doc.Sections.Add()
 Dim page As PdfPageBase = doc.Pages.Add()

Step2: Load an image to PDF and set image location

First, load an image of any format among jpg, bmp, png, gif, tif and ico from system. A tiff image is loaded and its location is being set in this method.

[C#]
//Load a tiff image from system
 PdfImage image = PdfImage.FromFile(@"D:\images\bear.tif");
//Set image display location and size in PDF
 float widthFitRate = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width;
 float heightFitRate = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height;
 float fitRate = Math.Max(widthFitRate, heightFitRate);
 float fitWidth = image.PhysicalDimension.Width / fitRate;
 float fitHeight = image.PhysicalDimension.Height / fitRate;
 page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight);
[VB.NET]
'Load a tif image from system
 Dim image As PdfImage = PdfImage.FromFile("D:\images\bear.tif")
 'Set image display location and size in PDF
 Dim widthFitRate As Single = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width
 Dim heightFitRate As Single = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height
 Dim fitRate As Single = Math.Max(widthFitRate, heightFitRate)
 Dim fitWidth As Single = image.PhysicalDimension.Width / fitRate
 Dim fitHeight As Single = image.PhysicalDimension.Height / fitRate
 page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight)

Step3: Save the image to PDF file and launch the file

[C#]
 //save and launch the file
 doc.SaveToFile("image to pdf.pdf");
 doc.Close();
 System.Diagnostics.Process.Start("image to pdf.pdf");
[VB.NET]
 'save and launch the file
 doc.SaveToFile("image to pdf.pdf")
 doc.Close()
 System.Diagnostics.Process.Start("image to pdf.pdf")
Monday, 11 July 2011 06:05

Convert XML to PDF in C#, VB.NET

A lot of reasons can be attributed to the common requirement of Office OpenXML to PDF conversion. Office OpenXML(Extensible Markup Language),is a document format that is both human-readable and machine-readable. Even it emphasizes simplicity, generality, and usability over the internet, it is not as conveniently applied, widely supported and safely managed as PDF document format. So this article introduces a solution of three lines of key code to quickly convert Office OpenXML to PDF.

Spire.Doc for .NET is a professional Word component for .NET, which allows users to realize the task of Office OpenXML to PDF conversion through three lines of key code. The first line is for you to load your Office OpenXML file from system by calling Spire.Doc.Document class instance method LoadFromFile; the second is to save the Office OpenXML file as Doc file format by invoking the method SaveToFile to pass a parameter FileFormat.Doc; with the last line, you can save your Doc as PDF file format by the same method SaveToFile to pass the other parameter FileFormat.PDF.

Please Download Spire.Doc for .NET and view the effective screenshot of converting Office OpenXML to PDF below first.

XML to PDF

Code sample of  converting Office OpenXML to PDF

[C#]
using Spire.Doc;

namespace XML2PDf
{
    class Program
    {
        static void Main(string[] args)
        {
            Document mydoc = new Document();
            mydoc.LoadFromFile(@"..\sample.xml", FileFormat.Xml);
            mydoc.SaveToFile("Test.doc", FileFormat.Doc);
            mydoc.SaveToFile("test.pdf", FileFormat.PDF);
            System.Diagnostics.Process.Start("Test.pdf");

        }
    }
}      
[VB.NET]
Imports Spire.Doc
Namespace XMLPDf
	Class Program
		Private Shared Sub Main(args As String())
			Dim mydoc As New Document()
			mydoc.LoadFromFile("..\sample.xml", FileFormat.Xml)
			mydoc.SaveToFile("Test.doc", FileFormat.Doc)
			mydoc.SaveToFile("test.pdf", FileFormat.PDF)
			System.Diagnostics.Process.Start("Test.pdf")

		End Sub
	End Class
End Namespace

Besides converting Office OpenXML to PDF, Spire.Doc also can convert Word to PDF, RTF to PDF, Word to Image/EPUB/HTML/Text/Office OpenXML/RTF/Tiff as well as convert HTML to Word/Image, RTF to HTML and Office OpenXML to Word. Click to know more about this Word .NET Component.

Friday, 08 July 2011 05:23

Excel to PDF in C#, VB.NET

In order to convert Excel to PDF in C#/VB.NET, you may have searched a lot, finding huge lines of codes but not perfect in quality. Here is the nice solution you are looking for. Within this section, we will demonstrate how to convert Excel to PDF using C#/VB.NET. This conversion will be successfully managed within just several lines of codes, but the quality will be absolutely perfect; As the PDF will be the same as your Excel file.

Spire.XLS for .NET is .NET Excel component which enables your .NET applications to fast generate, read, write and modify Excel document without Microsoft Office Excel Automation. It also fully supports converting files from Excel to PDF, Excel to HTML, Excel to CSV, Excel to Text, Excel to Image and Excel to XML. Any kind of trial and evaluation is always welcomed. Please feel free to download Spire.XLS for .NET to have a trial.

Spire.XLS now offers a new method to convert excel to PDF, which supports convert chart, shape and smart art in excel file to PDF. Please refer to new method of convert Excel to PDF.

The following is the code samples for converting Excel to PDF in C#/VB.NET. You can directly copy and paste into your project to have a try and convert your Excel to PDF for personal use.

[C#]
using Spire.Xls;
using Spire.Pdf;
using Spire.Xls.Converter;

namespace ExceltoPDF
{
    class Program
    {
        static void Main(string[] args)
        {
           // load Excel file
           Workbook workbook = new Workbook();
           workbook.LoadFromFile("D:\\test.xlsx");
 
           // Set PDF template
           PdfDocument pdfDocument = new PdfDocument();
           pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
           pdfDocument.PageSettings.Width = 970;
           pdfDocument.PageSettings.Height = 850;

           //Convert Excel to PDF using the template above
           PdfConverter pdfConverter = new PdfConverter(workbook);
           PdfConverterSettings settings = new PdfConverterSettings();
           settings.TemplateDocument = pdfDocument;
           pdfDocument = pdfConverter.Convert(settings);

           // Save and preview PDF
           pdfDocument.SaveToFile("sample.pdf");
           System.Diagnostics.Process.Start("sample.pdf");
        }
    }
}
[VB.NET]
Imports Spire.Xls
Imports Spire.Pdf
Imports Spire.Xls.Converter

Namespace ExceltoPDF
	Class Program
		Private Shared Sub Main(args As String())
			' load Excel file
			Dim workbook As New Workbook()
			workbook.LoadFromFile("D:\test.xlsx")

			' Set PDF template
			Dim pdfDocument As New PdfDocument()
			pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape
			pdfDocument.PageSettings.Width = 970
			pdfDocument.PageSettings.Height = 850

			'Convert Excel to PDF using the template above
			Dim pdfConverter As New PdfConverter(workbook)
			Dim settings As New PdfConverterSettings()
			settings.TemplateDocument = pdfDocument
			pdfDocument = pdfConverter.Convert(settings)

			' Save and preview PDF
			pdfDocument.SaveToFile("sample.pdf")
			System.Diagnostics.Process.Start("sample.pdf")
		End Sub
	End Class
End Namespace

After this code, you can run this application and you will see the PDF converted from Excel. Below is a comparison of the original Excel and target PDF, please have a check.

Excel to PDF

Page 105 of 107