How to export data from Magento 2 in XLS & XLSX formats

- E-Commerce, Magento 2

Magento 2 export CLI

Recently, we’ve come across a question by user00247 regarding how to export data from Magento 2 in an XLS format. Another StackExchange user proposed a solution that is also provided below. However, it is aimed at technical users only. Therefore, we’ve decided to elaborate the provided answer with an alternative solution, shedding light on how to export data from Magento 2 in XLS & XLSX formats and what’s the difference between them. Before going any further, pay heed to the fact that Magento 2 supports neither XLS nor XLSX files by default.


Bear in mind that we can help you with any import and export tasks that take place in Magento 2. Contact us for further information.

Understanding xls and xlsx

XLS is a standard file extension for a spreadsheet file format created for storing Microsoft Excel documents, known as the Binary Interchange File Format (BIFF). In its turn, XLSX is another kind of Microsoft Excel spreadsheets that features calculation, graphing tools, pivot tables, and macro programming. As you might know, the latter is the latest version of Microsoft Excel while the former is the older one. Thus, XLS is associated with the 2003 version of Excel, while XLSX is related to versions since 2007.

It is also necessary to mention that XLSX and XLS files store information differently. As we’ve just mentioned, XLS is based on BIFF, keeping all the data ordered in a binary format. As for XLSX, it incorporates the Office Open XML format, storing all the data in a text file that utilizes XML for defining parameters.

Also, the performance of the two file types differs. XLS files are faster than XLSX when you use complex formulas and large sets of data.

It is also worth mentioning that XLS files are supported in all Excel versions while XLSX sheets can be processed in Microsoft Excel versions 2007 and onwards. 

From the perspective of Magento 2 data export, XLS and XLSX are quite similar and interchangeable. If you want to process data files in Excel 2007+ you can freely use XLSX instead of XLS. If your editor is older, you either need to run the XLS export or convert XLSX into XLS. So, how to export data from Magento 2 via XLS?

How to export XLS files from Magento 2

Nilesh Gosai proposes the following solution to export data from Magento 2 via XLS files:

Firstly, he recommends adding the following code in (“app/code/NameSpace/Module/view/adminhtml/ui_component/”) listing the XML file between <listingToolbar> and </listingToolbar> tags:

Secondly, it is necessary to create the “GridToXls.php” file in app/code/Namespace/Module/Controller/Adminhtml/Export. Add the following code to the file:

Thirdly, the “ConvertToXls.php” file is required. Create it in app/code/Namespace/Module/Model/Export with the following code inside:

Since this approach doesn’t look very merchant-friendly, we’d also like to draw your attention to an alternative solution with XLSX files instead of XLS.

How to export XLSX files from Magento 2

You need a third-party extension to enable the XLSX export in Magento 2. Meet the Improved Import & Export extension! It not only lets you transfer XLSX files from your e-commerce website but also supports such standards as: 

  • CSV;
  • XML;
  • JSON;
  • ODS;
  • ZIP & TAR.

Besides, the module offers extensive mapping capabilities. You can freely export data in a format suitable for your external integrations. Although you cannot transfer Magento 2 attributes straight to a third-party system, since it has its unique standards and requirements, the Improved Import & Export lets you do that. You either apply a mapping preset or match native Magento 2 attributes to ones utilized by the platform you connect your website to. 

Magento 2 attribute mapping import and export

Various data editing capabilities enable you to merge and split data, add suffixes and prefixes, create missing attributes on the fly, etc. 

Besides, the Improved Import & Export extension supports data transfer automation. The module launches data transfers according to schedule. At the same time, you can leverage various triggers. Thus,  you can export data from Magento 2 in XLSX daily, weekly, or monthly as well as after a particular event – a new order is placed – takes place.

Magento 2 all product types import and export

And for various complex integrations, Improved Import & Export utilizes API connections, creating a robust data flow between your e-commerce store and an external system. 

Last but not least, our module has a set of plug-ins that simplify particular integrations. For instance, SAP Business One Integration Add-on for Magento 2 lets you synchronize the two systems within just a few clicks. 

For further information about our extension, follow this link:

Get Improved Import & Export Magento 2 Extension

You can find more export and import tips for Magento 2 in our cookbook.