{"id":874,"date":"2014-07-07T10:02:40","date_gmt":"2014-07-07T10:02:40","guid":{"rendered":"http:\/\/mindfusion.eu\/blog\/?p=874"},"modified":"2021-01-14T11:21:25","modified_gmt":"2021-01-14T11:21:25","slug":"mindfusion-spreadsheet-formatted-text","status":"publish","type":"post","link":"https:\/\/mindfusion.dev\/blog\/mindfusion-spreadsheet-formatted-text\/","title":{"rendered":"MindFusion.Spreadsheet: Formatted Text"},"content":{"rendered":"<p>Starting with version 1.2, MindFusion.Spreadsheet adds support for formatted text. The control can import, create, display and export formatted texts. In this blog we will demonstrate how to create formatted text in a cell.<\/p>\n<p><b>Introduction<\/b><\/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><b>Creating the formatted text<\/b><\/p>\n<p>Formatted texts are created programmatically by instantiating from the FormattedText class. The class provides a constructor, which can initialize the formatted text from a markup string, similar to HTML. The string supports the following tags: &lt;fontname=&#8221;<i>fontname<\/i>&#8220;&gt;, &lt;fontsize=&#8221;<i>fontsize<\/i>&#8220;&gt;, &lt;i&gt;, &lt;b&gt;, &lt;u&gt;, &lt;s&gt;, and &lt;color=&#8221;<i>#rrggbb<\/i>&#8220;&gt;. The following code creates several formatted texts:<\/p>\n<pre>worksheet.Cells[\"A1\"].Data = new FormattedText(\"The meeting is <b>&lt;color=\\\"#ff0000\\\"&gt;important&lt;\/color=\\\"#ff0000\\\"&gt;<\/b>!\");\nworksheet.Cells[\"A2\"].Data = new FormattedText(\"&lt;fontsize=\\\"18\\\"&gt;A title &lt;fontsize=\\\"8\\\"&gt;(1994)\");\nworksheet.Cells[\"A3\"].Data = new FormattedText(\"This text contains some <i><u>keywords<\/u><\/i> that are <i><u>highlighted<\/u><\/i>.\");&lt;\/fontsize=\\\"8\\\"&gt;&lt;\/fontsize=\\\"18\\\"&gt;<\/pre>\n<p><b>Exporting<\/b><\/p>\n<p>The formatted texts are exported to all supported formats, including HTML, PDF, XLSX, ODS, image, and so on. The following image illustrated the formatted texts created earlier exported to HTML:<\/p>\n<p><a href=\"http:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/07\/spreadsheet-formattedtext.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-886\" src=\"http:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/07\/spreadsheet-formattedtext-300x188.png\" alt=\"spreadsheet-formattedtext\" width=\"300\" height=\"188\" srcset=\"https:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/07\/spreadsheet-formattedtext-300x188.png 300w, https:\/\/mindfusion.dev\/blog\/wp-content\/uploads\/2014\/07\/spreadsheet-formattedtext.png 587w\" 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\/SpreadsheetFormattedTexts.zip\">https:\/\/mindfusion.dev\/_samples\/SpreadsheetFormattedTexts.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><i>About MindFusion.Spreadsheet for WinForms<\/i>: A powerful .NET spreadsheet component with great capabilities for editing, styling and formatting large amounts of data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Starting with version 1.2, MindFusion.Spreadsheet adds support for formatted text. The control can import, create, display and export formatted texts. In this blog we will demonstrate how to create formatted text in a cell. Introduction As with all previous blogs &hellip; <a href=\"https:\/\/mindfusion.dev\/blog\/mindfusion-spreadsheet-formatted-text\/\">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":[165,31,242,97,164,166,192],"class_list":["post-874","post","type-post","status-publish","format-standard","hentry","category-sample-code","category-spreadsheet","tag-excel","tag-export","tag-formatted-texts","tag-html","tag-spreadsheet-2","tag-workbook","tag-worksheet"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3RlKs-e6","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/posts\/874","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=874"}],"version-history":[{"count":9,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/posts\/874\/revisions"}],"predecessor-version":[{"id":2502,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/posts\/874\/revisions\/2502"}],"wp:attachment":[{"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/media?parent=874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/categories?post=874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mindfusion.dev\/blog\/wp-json\/wp\/v2\/tags?post=874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}