{"id":824,"date":"2014-06-02T12:02:18","date_gmt":"2014-06-02T12:02:18","guid":{"rendered":"http:\/\/mindfusion.eu\/blog\/?p=824"},"modified":"2021-01-14T11:10:54","modified_gmt":"2021-01-14T11:10:54","slug":"mindfusion-spreadsheet-convert-xlsx-to-pdf","status":"publish","type":"post","link":"https:\/\/mindfusion.dev\/blog\/mindfusion-spreadsheet-convert-xlsx-to-pdf\/","title":{"rendered":"MindFusion.Spreadsheet: Convert XLSX to PDF"},"content":{"rendered":"<p>In this blog we will discuss how to convert an existing XSLX file to PDF using MindFusion.Spreadsheet for WinForms.<\/p>\n<p><strong>Introduction<\/strong><\/p>\n<p>As with all previous blogs we start off by creating a new Windows Forms Application in Visual Studio and adding a WorkbookView control to the main form. The WorkbookView displays a Workbook with a single worksheet.<\/p>\n<p><strong>Importing the XLSX file<\/strong><\/p>\n<p>In MindFusion.Spreadsheet XLSX files are imported using instances of the ExcelImporter class. For the purposes of this blog we will import an existing <em>report.xlsx<\/em> file, contained in the zip of the sample. To import this file, use the following code:<\/p>\n<pre>var importer = new ExcelImporter();\nimporter.Import(Path.Combine(path, \"report.xlsx\"), workbook1);<\/pre>\n<p><strong>Creating the PDF<\/strong><\/p>\n<p>To create a PDF file from the imported worksheet, create an instance of the PdfExprter class and call its Export method:<\/p>\n<pre>var exporter = new PdfExporter();\nexporter.EnableGridLines = true;\nexporter.Export(workbook1.Worksheets[0], Path.Combine(path, \"report.pdf\"));<\/pre>\n<p>The following image illustrates the result of the conversion:<\/p>\n<p><a href=\"http:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/06\/spreadsheet-pdfexport.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-825\" src=\"http:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/06\/spreadsheet-pdfexport-300x218.png\" alt=\"spreadsheet-pdfexport\" width=\"300\" height=\"218\" srcset=\"https:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/06\/spreadsheet-pdfexport-300x218.png 300w, https:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/06\/spreadsheet-pdfexport-1024x745.png 1024w, https:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/06\/spreadsheet-pdfexport.png 1033w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The source code of the sample is available for download from here:<\/p>\n<p><a href=\"https:\/\/mindfusion.dev\/_samples\/SpreadsheetConvertPdf.zip\">https:\/\/mindfusion.dev\/_samples\/SpreadsheetConvertPdf.zip<\/a><\/p>\n<p>The trial version of MindFusion.Spreadsheet for WinForms can be downloaded from here:<\/p>\n<p><a href=\"https:\/\/mindfusion.dev\/SpreadsheetTrial.zip\">Download MindFusion.Spreadsheet for WinForms Trial Version<\/a><\/p>\n<p><em>About MindFusion.Spreadsheet for WinForms<\/em>: A powerful .NET spreadsheet component with great capabilities for editing, styling and formatting large amounts of data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog we will discuss how to convert an existing XSLX file to PDF using MindFusion.Spreadsheet for WinForms. Introduction As with all previous blogs we start off by creating a new Windows Forms Application in Visual Studio and adding &hellip; <a href=\"https:\/\/mindfusion.dev\/blog\/mindfusion-spreadsheet-convert-xlsx-to-pdf\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[74,163],"tags":[221,165,31,136,30,164,166,192],"class_list":["post-824","post","type-post","status-publish","format-standard","hentry","category-sample-code","category-spreadsheet","tag-convert","tag-excel","tag-export","tag-import","tag-pdf","tag-spreadsheet-2","tag-workbook","tag-worksheet"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3RlKs-di","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/posts\/824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/comments?post=824"}],"version-history":[{"count":3,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/posts\/824\/revisions"}],"predecessor-version":[{"id":2493,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/posts\/824\/revisions\/2493"}],"wp:attachment":[{"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/media?parent=824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/categories?post=824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/tags?post=824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}