MindFusion WinForms Spreadsheet Control: Convert XLSX to PDF

This blog demonstrates how easily you can convert XLSX files to PDF using the Windows Forms Spreadsheet control.

Setup

Create a new WinForms application and add the necessary assemblies to the project. Add a WorkbookView control to the main application window. Note, that this is not necessary for the conversion – it is done only to display the original XLSX file.

Perform the conversion

Add a button to the main form, set its text to ‘Convert…’ and handle its Click event. In the event handler display an OpenFileDialog to query the user for the input XLSX file, then display a SaveFileDialog to request the target PDF file. Once the two files are specified, proceed with the conversion by creating an ExcelImporter and PdfExporter objects and using their Import and Export methods in succession:

// Import the data
var importer = new ExcelImporter();
importer.Import(xlsxPath, workbook1);

// Export the worksheet as PDF
var exporter = new PdfExporter();
exporter.EnableGridLines = true;
exporter.Export(workbook1.Worksheets[0], pdfPath);

// Open the PDF
System.Diagnostics.Process.Start(pdfPath);

The xlsxPath and pdfPath variables identify the respective XLSX and PDF file names. The workbook1 variable represents the Workbook displayed on the form. Once the conversion is complete, the PDF file is opened in the default PDF viewer by calling Process.Start.

The following image illustrates the result:

The source code of the project together with all necessary libraries can be downloaded from here:

Convert .XLSX to .PDF Files Using the WinForms Spreadsheet Control: Download Sample

You are welcome to ask any questions about the WorkbookView control at MindFusion discussion board or per e-mail at support@mindfusion.eu.

Click here here to visit the official page of the MindFusion WinForms Spreadsheet control.

We hope you find this tutorial useful and thank you for your interest in MindFusion developer tools.

MindFusion.WinForms Pack 2014.R3

MindFusion is pleased to announce the release 2014.R3 of the Pack for WinForms component suite. Here is an overview of the new features:

diagram16x16MindFusion.Diagramming

Export to Visio 2013 files
The new Visio2013Exporter class lets you export the contents of Diagram and DiagramDocument objects to Visio 2013 VSDX files. You must add a reference to the MindFusion.Diagramming.Export.Visio.dll assembly beforehand. Further details on how to use the Visio2013Exporter can be found in the forum or the online help.

Headers and Footers in PDF
You can now add a header and a footer to all exported to PDF pages. Their content and font are customizable – use HeaderFormat, HeaderFont, FooterFormat and FooterFont to do it.

The PdfExporter

The PdfExporter

Calendar-16x16MindFusion.Scheduling

New Holiday Providers
You can use one of the new holiday providers, added to the MindFusion.HolidayProviders.dll assembly – FranceHolidayProvider, GermanyHolidayProvider, RussiaHolidayProvider, and UKHolidayProvider.

Miscellaneous

  • A new Drawing event enables custom drawing of calendar elements before their default rendering.
  • Improved support for partial databinding.

Spreadsheet-16x16MindFusion.Spreadsheet

Export to XLSX (Office Open XML) format
Use the new ExcelExporter class to export MindFusion.Spreadsheet Workbook objects to Excel. To export a workbook to XLSX, create an instance of the ExcelExporter class and call its Export method, passing the Workbook object as parameter.

Export to ODS (OpenDocument Spreadsheet) format
The new CalcExporter class lets you export MindFusion.Spreadsheet Workbook objects to the OpenDocument format. To export a workbook, create an instance of the CalcExporter class and call its Export method, passing the Workbook object as parameter.

Export to XHTML and MHTML format
Two new classes – HtmlExporter and MhtmlExporter – let you export MindFusion.Spreadsheet Workbook objects to (X)HTML and MHTML files. To export a workbook, create an instance of the respective exporter class and call its Export method, passing the Workbook object as parameter.

Export to XHTML.

Export to XHTML.

Moving cell ranges
You can move cells and cell ranges programmatically as well interactively. In order to move a column/row programmatically you should call one of the Move overloads of the of the ColumnCollection or RowCollection classes respectively, and specify the column/row to move and the desired location. To move columns or rows interactively, select the columns or rows entirely, click on any of the selected column or row headers and drag.

Find and replace
You can now use a variety of methods to search and replace texts. For searching, use the Find and FindAll methods. For replacing text use Replace and ReplaceAll. The new FindReplaceForm class (contained in the MindFusion.Spreadsheet.WinForms.StandardForms.dll assembly) can be used to facilitate search and replace operations inside a workbook.

Improved in-place editing
In-place formula editing has been extended with automatic literal, string, cell and cell range coloring
and context-sensitive tooltip information for functions.

In-place editing.

In-place editing.

Miscellaneous

  • The parameters of the Export methods of some exporters have been reordered to improve consistency. Now the Worksheet/Workbook being exported is always the first argument.
  • The HyperlinkForm constructors now require an addition argument of type Workbook.
  • New PageOrientation property added to the PdfExporter class.

uiMindFusion.UI

DockControl
Layout serialization has been added to the DockControl.

The trial version is available for direct download from this link:

Download MindFusion.WinForms Pack 2014.R3

If you run into problems with any of the components, please let us know. We shall be glad to assist you. MindFusion is proud with its excellent technical support – the majority of the questions are answered within hours of receiving them.

About MindFusion.WinForms Pack: A set of five WinForms programming components that provide your application with a rich choice of diagramming, charting, scheduling, mapping, reporting and gauge features. The tools are very easy to implement and use. They boast intuitive API and various step-by-step tutorials to get you started. Both online and offline documentation is available.

A sample browser presents you with all the samples for each control to let you easily navigate to what you need. You can check some of the features of each component right now if you look at the online demos:

Visit the features – page of the components for more information about their capabilities:

You can check the prices and licensing scheme here. All components are royalty-free.

MindFusion.Spreadsheet: Import and Export

The following scheme illustrates the file formats supported by MindFusion.Spreadsheet for WinForms:

spreadsheet-formats

Importing

MindFusion.Spreadsheet can load data from CSV (comma-separated values), XLSX (Office Open XML), ODS (OpenDocument Spreadsheet), and its native binary and XML formats. The files are imported through a set of importer classes: CsvImporter for CSV, ExcelImporter for XLSX, and CalcImporter for ODS. To import a file, create an instance of the respective importer class, set the necessary properties, and call its Import method. The following code demonstrates how to import a workbook from an existing XLSX file:

var excelImporter = new ExcelImporter();
excelImporter.Import(workbook, @"d:\workbook.xlsx");

Importing from CSV can be further facilitated through the use of a built-in CsvImportForm. The form provides the user interface to enter various options and preview the data before it is actually imported.

Exporting

MindFusion.Spreadsheet can export data to a variety of formats, including image, PDF, CSV, XLSX, ODS, HTML and MHTML. In addition the workbooks can be previewed and printed to paper and XPS. The workbooks and worksheets are exported through a set of exporter classes: ImageExporter for images, PdfExporter for PDF, CsvExporter for CSV, ExcelExporter for XLSX, CalcExporter for ODS, HtmlExporter for XHTML, and so on. Printing is done through the WorkbookPrinter class. To export a workbook, create an instance of the respective exporter class, set the necessary properties, and call the Export method. The following code demonstrates how to export a workbook to ODS:

var calcExporter = new CalcExporter();
calcExporter.Export(workbook, @"c:\mysheet.ods");

The following image illustrates a workbook exported to an XHTML file using the HtmlExporter class:

spreadsheet-xhtmlexport

Additional information about the importing and exporting capabilities of MindFusion.Spreadsheet can be found in the online documentation of the component:

http://www.mindfusion.eu/onlinehelp/spreadsheetwinforms/index.htm?Importing.htm
http://www.mindfusion.eu/onlinehelp/spreadsheetwinforms/index.htm?Exporting_0.htm

The trial version of MindFusion.Spreadsheet for WinForms can be downloaded from here:

Download MindFusion.Spreadsheet for WinForms Trial Version

About MindFusion.Spreadsheet for WinForms: A powerful .NET spreadsheet component with great capabilities for editing, styling and formatting large amounts of data.

Spreadsheet for WinForms, V1.1 Released

MindFusion has released Spreadsheet for WinForms 1.1. Here is an overview of the new features:

Export to XLSX (Office Open XML) format
You can use the new ExcelExporter class to export MindFusion.Spreadsheet Workbook objects to Excel. The export is very easy to do – just create an instance of the ExcelExporter class and call its Export method, passing the Workbook object as a parameter.

Export to ODS (OpenDocument Spreadsheet) format
You can now export MindFusion.Spreadsheet Workbook objects to the OpenDocument format. To export a workbook, simply create an instance of the new CalcExporter class and call its Export method, passing the Workbook object as a parameter.

Moving cell ranges
You can now move cells and cell ranges both programmatically and interactively. To move a cell range programmatically, call one of the MoveTo overloads of a CellRange object representing the range to move and specify the destination. To move a range interactively, select the range, click near the end of the selection rectangle and drag the rectangle to the desired location. If you want to disable interactive movement set the AllowMoveCells property of the WorkbookView class to false.

Rows, columns and cell ranges can be moved either programmatically or interactively with the mouse.

Rows, columns and cell ranges can be moved either programmatically or interactively with the mouse.

Moving rows and columns
You can move columns and rows programmatically as well interactively. To move a column/row programmatically, call one of the Move overloads of the ColumnCollection or RowCollection classes respectively, and specify the column/row to move and the desired location. To move columns or rows interactively, select the columns or rows entirely, click on any of the selected column or row headers and drag.

Find and replace
The workbook now provides a set of methods for searching and replacing text. You can search text with the Find and FindAll methods. The former searches for the first cell containing a given text, the later returns all cells matching the criteria. To replace text, use the Replace and ReplaceAll methods.

Improved in-place editing
You can use the extended in-place formula editing, which supports automatic literal, string, cell and cell range coloring and context-sensitive tooltip information for functions. The information for custom functions can be provided through the new ExtendedInformationProvider property of the Workbook class.

You can download the trial version from the link below:

Download MindFusion.Spreadsheet for WinForms 1.1, Trial Version

If you require technical support, you can post a message at the forum, send us an e-mail at support@mindfusion.eu. or use the help desk. MindFusion takes special effort in providing fast and detailed answers to all inquiries that we receive.

About MindFusion.Spreadsheet for WinForms: An easy-to-use programming component suitable for building all types of spreadsheets fast and easy. The tool supports formulas, tool-tips, cell annotations, cell spanning, scrolling and many more. You can add charts and images as well use the flexible style system to design the perfect spreadsheet. The component supports full undo and redo as well copy and paste from Windows clipboard.
You can import spreadsheet data from CSV, XLSX or ODS files and export the final spreadsheet in a number of formats – as images, PDF or CSV, XLSX or ODS files. Various auxiliary forms help you quickly adjust the data and appearance of your spreadsheet. Read more about the features of the component here or check the license prices at the buy page.

Spreadsheet for WinForms is part of MindFusion Pack for WinForms, which offers other useful components that are of great use when you build any type of WinForms application – from a diagramming library to map control to gauges: check them here.

MindFusion.Spreadsheet for WinForms Beta Version

MindFusion.Spreadsheet is a spreadsheet component that can be used to create, open, manage, and export spreadsheet documents in many different formats without requiring Microsoft Excel. It is implemented as a .NET control and can be easily integrated into any application targeting the Microsoft .NET platform.

MindFusion.Spreadsheet supports:

  • Importing documents from CSV, XLSX, ODS
  • Export to PDF,CSV,image
  • Numerous chart types
  • Customizable cell appearance
  • Merged cells
  • Conditional formatting
  • Data validation
  • Images
  • Cell annotations
  • Previewing and printing
  • Undo and redo
  • Auxiliary forms
MindFusion.Spreadsheet lets you use an impressive range of calculation formulas.

MindFusion.Spreadsheet lets you use an impressive range of calculation formulas.

MindFusion.Spreadsheet provides intuitive user-interaction model for creating or editing spreadsheet documents. Its programmatic interface is powerful and simple to use. The control has been tested with the most popular .NET development environments and programming languages.

The beta version of the component is available for download from this link:

Download MindFusion.Spreadsheet for WinForms Beta Version

You can learn more about the features of the component here. Take a look at the gallery, which illustrates some of the capabilities of the control. Online documentation is also available at this link.

For technical support, please write at the forum or use email support@mindfusion.eu. You can also use the help desk.

Numerous chart types are available.

Numerous chart types are available.