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

- E-Commerce, Magento 2

Magento 2 export CLI

The default import and export capabilities of Magento 2 are fairly limited. Depending on the platform’s editions, they vary a little bit but neither of the existing versions lets you work with XLS and XLSX files by default. However, you can implement the missing functionality with a few lines of code or a third-party solution. 

In the following article, we depict the background of XLSX and XLS files and try to figure out what’s wrong with Magento 2 regarding them. You will find the existing solution to the problem posted on StackExchange. Since it is quite complex and not suitable for most merchants, we also provide a more user-friendly way of exporting data from Magento 2 in XLS & XLSX formats.

Recently, we’ve come across a question by user00247 where they ask how to export data from Magento 2 in an XLS format. Another StackExchange user proposes a solution that is provided below. Since it is aimed at technical users only, we’ve decided to elaborate the provided answer with an alternative, shedding light on how to export data from Magento 2 in XLS & XLSX formats for non-technical users. You will discover the difference between the two approaches and pick the one that is more suitable for you.

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 spreadsheet 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.

Magento 2 XLSX Export FAQ

How to export XLSX files from Magento 2 automatically?

The Improved Import & Export Magento 2 extension provides the ability to automate data transfers from your e-commerce website. The module relies on a cron scheduler so that you can choose predefined intervals or create custom ones for your export jobs. The same functionality is available for import processes.

How to export XLSX files suitable for external systems?

Our module offers robust mapping functionality. It lets you apply changes to the exported data right within the admin. As a result, you create output suitable for any system. The same tools are available for import processes. Improved Import & Export lets you match any external attributes to the ones used in Magento 2. The best thing is that you can save the created schemes for further data transfers.

Is it possible to import XLSX files to Magento 2?

Yes, you can use the Improved Import & Export extension for both import and export processes associated with XLSX files.

What entities can I export from Magento 2 via XLSX files?

You can transfer all the core entities via XLSX files to Magento 2 with Improved Import & Export. The extension supports products, categories, customers, advanced pricing, product attributes, orders, cms pages, cms blocks, catalog & cart rules, gift cards, reviews, url rewrites, search terms and synonyms, widgets, page hierarchy, newsletter subscribers, and other. Besides, you can export B2B entities using the corresponding add-on. Feel free to transfer company accounts, requisition lists, quotes, and others via XLSX from Magento 2. Note that you can import all this data to Magento 2 via XLSX using the same extension.

What file sources can I use to export XLSX files from Magento 2?

The Improved Import & Export extension lets you export XLSX files to FTP/SFTP, Google Drive, Dropbox, and OneDrive. Witn it comes to import processes, it is possible to transfer XLSX files from the same destinations as well as using direct URLs or uploading files straight to Magento 2.

What other file formats are supported?

With the Improved Import & Export module, you can transfer data using not only XLSX files but also CSV, XML, ODS, and JSON. All these data standards are supported in import and export processes.

What alternative ways of data transfers are possible?

With the Improved Import & Export Magento 2 module you can avoid file transfers due to support for Google Sheets. The extension lets you import data right from this service. Besides, the plugin lets you establish API connections with external systems, creating a seamless data flow between your Magento 2 website and any platform beyond.