{"id":6009,"date":"2019-03-21T17:18:43","date_gmt":"2019-03-21T14:18:43","guid":{"rendered":"https:\/\/dhtmlx.com\/blog\/?p=6009"},"modified":"2024-08-10T13:48:44","modified_gmt":"2024-08-10T10:48:44","slug":"dhtmlxspreadsheet-3-1-import-export-excel-number-formatting","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/dhtmlxspreadsheet-3-1-import-export-excel-number-formatting\/","title":{"rendered":"dhtmlxSpreadsheet 3.1: Import and Export to Excel, Number Formatting, and More"},"content":{"rendered":"<p>We continue to gradually enhance our JavaScript components &#8211; and now it&#8217;s the turn of dhtmlxSpreadsheet to receive new powers and abilities.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/javascript-spreadsheet.png\" alt=\"javascript spreadsheet v3.1\" width=\"900\" height=\"497\" class=\"aligncenter size-full wp-image-6041\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/javascript-spreadsheet.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/javascript-spreadsheet-300x166.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/javascript-spreadsheet-768x424.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p>The <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxSpreadsheet\/\" rel=\"noopener\" target=\"_blank\">JavaScript spreadsheet<\/a> was completely updated 4 months ago. The recent minor v3.1 brings out several features, which are essential for conveniently working with data:<\/p>\n<ul>\n<li>Export of data from Spreadsheet to Excel<\/li>\n<li>Import of data from Excel to Spreadsheet<\/li>\n<li>Number formatting<\/li>\n<li>Auto filling of cells<\/li>\n<li>Hotkeys behavior in a range of cells<\/li>\n<\/ul>\n<p>Before we go over the release details &#8211; download the latest <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxSpreadsheet\/download.shtml\" rel=\"noopener\" target=\"_blank\">trial version of JavaScript spreadsheet<\/a> 3.1 to test it on the fly.<\/p>\n<h5>Import and Export to Excel<\/h5>\n<p>The current update enables end users to import Excel data into a web spreadsheet component as well as export data from Spreadsheet to Excel.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/bandicam-2019-03-21-12-58-07-001.png\" alt=\"Export and import of Excel data into Spreadsheet\" width=\"901\" height=\"502\" class=\"aligncenter size-full wp-image-6028\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/bandicam-2019-03-21-12-58-07-001.png 901w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/bandicam-2019-03-21-12-58-07-001-300x167.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/bandicam-2019-03-21-12-58-07-001-768x428.png 768w\" sizes=\"auto, (max-width: 901px) 100vw, 901px\" \/><strong>Check the samples with <a href=\"https:\/\/docs.dhtmlx.com\/spreadsheet\/samples\/02_usage\/03_import_xlsx.html\" rel=\"noopener\" target=\"_blank\">import of Excel data into Spreadsheet <\/a>and <a href=\"https:\/\/docs.dhtmlx.com\/spreadsheet\/samples\/02_usage\/04_export_xlsx.html\" rel=\"noopener\" target=\"_blank\">export of Spreadsheet data to Excel ><\/a><\/strong><\/p>\n<p>The export and import operations became possible due to our two new WebAssembly-based libraries <a href=\"https:\/\/github.com\/dhtmlx\/excel2json\" rel=\"noopener\" target=\"_blank\">Excel2Json<\/a> and <a href=\"https:\/\/github.com\/dhtmlx\/json2excel\" rel=\"noopener\" target=\"_blank\">Json2Excel<\/a>. These libraries were developed by our team as open-source tools for converting Excel files into the JSON format and vice versa. They make use of the Rust programming language and WebAssembly.<\/p>\n<p>In order to use the export and import of Excel files into your JavaScript spreadsheet, you only need to take 3 steps:<br \/>\n1) Install the corresponding library for export and import<br \/>\n2) Specify the necessary options in the Spreadsheet configuration and link the component to the installed libraries<br \/>\n3) Apply the related API methods<\/p>\n<p>Read a detailed instruction on the <a href=\"https:\/\/docs.dhtmlx.com\/spreadsheet\/loading_data\/\" rel=\"noopener\" target=\"_blank\">import of data to Excel<\/a> and <a href=\"https:\/\/docs.dhtmlx.com\/spreadsheet\/loading_data\/#exporting-data\" rel=\"noopener\" target=\"_blank\">export of data to Excel<\/a> in the documentation.<\/p>\n<h5>Number Formatting<\/h5>\n<p>V3.1 comes out with an ability to set different formats for numeric values in cells. Spreadsheet default <a href=\"https:\/\/docs.dhtmlx.com\/spreadsheet\/number_formatting\/\" rel=\"noopener\" target=\"_blank\">number formats<\/a> are common (&#8220;&#8221;), currency (&#8220;$#,##0.00&#8221;), number (&#8220;#,##0.00&#8221;), and percent (&#8220;#,##0.00%&#8221;). <\/p>\n<p>Applying a number format to a value is easy with the <strong>setFormat<\/strong> method:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"co1\">\/\/ applies the currency format to the cell A1<\/span><br \/>\nspreadsheet.<span class=\"me1\">setFormat<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;A1&quot;<\/span><span class=\"sy0\">,<\/span><span class=\"st0\">&quot;currency&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>Besides, there is the <strong>getFormat<\/strong> method, which allows you to define what number format is applied for a particular cell:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> format <span class=\"sy0\">=<\/span> spreadsheet.<span class=\"me1\">getFormat<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;A1&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <br \/>\n<span class=\"co1\">\/\/ -&gt;&quot;currency&quot;<\/span><\/div><\/div>\n<p>On top of all, you can modify the default number formats or even create custom formats via the <strong>formats<\/strong> configuration option. For example, you can change the name of the predefined currency format for &#8220;U.S. dollar&#8221; and add two new formats with ids &#8211; &#8220;euro&#8221; and &#8220;franc&#8221;:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> spreadsheet <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">Spreadsheet<\/span><span class=\"br0\">&#40;<\/span>document.<span class=\"me1\">body<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; formats<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;U.S. Dollar&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;currency&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mask<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;$#,##0.00&quot;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;Euro&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;euro&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mask<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;[$\u20ac]#.##0,00&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; example<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;1000.50&quot;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;Swiss franc&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;franc&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mask<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;[$CHF ]#.##0,00&quot;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/Custom-number-formatting.png\" alt=\"Custom number formatting\" width=\"900\" height=\"500\" class=\"aligncenter size-full wp-image-6035\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/Custom-number-formatting.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/Custom-number-formatting-300x167.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/Custom-number-formatting-768x427.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><strong><a href=\"https:\/\/docs.dhtmlx.com\/spreadsheet\/samples\/03_configuration\/06_custom_formats.html\" rel=\"noopener\" target=\"_blank\">Check the sample ><\/a><\/strong><\/p>\n<p>By the way, our Spreadsheet component automatically detects the format of content in cells due to the <strong>autoFormat<\/strong> configuration option enabled by default. However, you are free to disable it if you want.<\/p>\n<h5>Automatic Filling of Cells with Content<\/h5>\n<p>From now on, there is no more need for tediously typing in data by hand, as our JavaScript Spreadsheet is able to fill cells with data automatically. The autofill is based on a range of widespread patterns. For instance, in order to get a sequence of consecutive numbers from 1 to n, you just need to enter 1 and 2 into the first two cells and drag the fill handle to grab and autofill as many cells as you need. The spreadsheet can also automatically create sequences of odd and even numbers. Moreover, there is a pattern for making a series of numbers with letters.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/Auto-filling-of-cells-1.gif\" alt=\"Auto filling of cells\" width=\"800\" height=\"443\" class=\"aligncenter size-full wp-image-6053\" \/><strong><a href=\"https:\/\/dhtmlx-docs.gitbook.io\/spreadsheet-user-guide\/work-with-cells#auto-filling-cells-with-content\" rel=\"noopener\" target=\"_blank\">Check the user guide ><\/a><\/strong><\/p>\n<h5>Enhanced Hotkeys Navigation<\/h5>\n<p>We&#8217;ve improved hotkeys behavior for easier spreadsheet navigation inside a range of cells:<\/p>\n<ul>\n<li><strong>Enter<\/strong> &#8211; moves the selected cell down within the selected range<\/li>\n<li><strong>Shift + Enter<\/strong> &#8211; moves the selected cell up within the selected range<\/li>\n<li><strong>Tab<\/strong> &#8211; moves the selected cell right within the selected range<\/li>\n<li><strong>Shift + Tab<\/strong> &#8211; moves the selected cell left within the selected range<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/03\/hotkeys-behavior.gif\" alt=\"Hotkeys behavior in a range of cells\" width=\"800\" height=\"446\" class=\"aligncenter size-full wp-image-6033\" \/><strong><a href=\"https:\/\/dhtmlx-docs.gitbook.io\/spreadsheet-user-guide\/hot-keys\" rel=\"noopener\" target=\"_blank\">Check the user guide ><\/a><\/strong><\/p>\n<p>So the next step is to download dhtmlxSpreadsheet 3.1 <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxSpreadsheet\/download.shtml\" rel=\"noopener\" target=\"_blank\">free trial version<\/a> and test all the new features yourself!<\/p>\n<p>We&#8217;re looking forward to your feedback about the release &#8211; share your thoughts in the comments below or write to us: <a href=\"mailto:info@dhtmlx.com\">info@dhtmlx.com<\/a><\/p>\n<p>Current clients are invited to download the latest version in their <a href=\"https:\/\/dhtmlx.com\/clients\/\" rel=\"noopener\" target=\"_blank\">Client&#8217;s Area<\/a>. <\/p>\n<h5>Related Materials:<\/h5>\n<ul>\n<li><a href=\"https:\/\/snippet.dhtmlx.com\/wux2b35b?tag=spreadsheet\" rel=\"noopener\" target=\"_blank\">Spreadsheet samples<\/a><\/li>\n<li>Full <a href=\"https:\/\/docs.dhtmlx.com\/spreadsheet\/whats_new\/\" rel=\"noopener\" target=\"_blank\">&#8220;What&#8217;s new&#8221;<\/a> list in the documentation<\/li>\n<li>Open-source library for export of Excel data <a href=\"https:\/\/github.com\/dhtmlx\/excel2json\" rel=\"noopener\" target=\"_blank\">Excel2Json<\/a><\/li>\n<li>Open-source library for import of Excel data <a href=\"https:\/\/github.com\/dhtmlx\/json2excel\" rel=\"noopener\" target=\"_blank\">Json2Excel<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>We continue to gradually enhance our JavaScript components &#8211; and now it&#8217;s the turn of dhtmlxSpreadsheet to receive new powers and abilities. The JavaScript spreadsheet was completely updated 4 &#8230;<\/p>\n","protected":false},"author":101012,"featured_media":6060,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70,1,38],"tags":[33,34,4],"class_list":["post-6009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-releases","category-uncategorized","category-visible","tag-all-posts","tag-spreadsheet","tag-dhtmlx-updates"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/6009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=6009"}],"version-history":[{"count":4,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/6009\/revisions"}],"predecessor-version":[{"id":12714,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/6009\/revisions\/12714"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/6060"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=6009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=6009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=6009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}