This project is not covered by Drupal’s security advisory policy.

Views Data Export lets visitors download a View as a spreadsheet. For Excel (.xlsx) files it builds the whole spreadsheet in memory with PhpSpreadsheet. In batch mode it re-opens and re-saves the file on every batch, so large exports can take minutes or run out of memory. Views Data Export: Fast XLSX streams the same export row by row with the OpenSpout library. You switch it on per export display, with no other changes to your View, and the file downloads directly with a progress bar.

Example from a production site: an export of 55,000 rows went from about 270 seconds (Views Data Export batch) to about 8 seconds. An export of 350,000 rows finished in under a minute.

Features

  • One checkbox per display. A "Fast XLSX export" setting is added to every Views Data Export display. Displays where it is off keep working exactly as before.
  • Same View, same results. Views still builds the query, so filters, exposed filters, contextual filters, relationships, sorting, pager and export limit all apply. The URL, access rules and the export link on the page do not change.
  • Same output. Columns, labels and order come from the display's fields. The usual Views processing runs too (entity loading, hook_views_post_execute(), hook_views_pre_render(), field pre-render), so modules that change results keep working. The Views Data Export "Alias" and "Raw output" field options are respected.
  • Fast where possible, correct everywhere. Common fields (numbers, dates, plain text, single-value text fields, simple {{ field }} rewrites) are formatted straight from the database using the same rules as Views. Any other field (links, formatters, Twig rewrites, custom field plugins) is rendered by Views as before. Fields whose plugin class has been replaced or extended fall back to Views rendering automatically.
  • Better spreadsheets. Numbers are real Excel numbers with the configured decimals and thousands separator, so they can be summed and sorted. The header row is bold, and sheets are right-to-left for RTL languages.
  • Progress bar. Clicking the export link shows a dialog ("Exported 12,000 of 55,033 rows") that the user can cancel. The dialog is isolated from theme CSS, so it looks the same under any theme. Without JavaScript the link still downloads the file directly.
  • Safe limits. Exports that are missing required filters, or that have more rows than your limit (Excel's limit by default), send the user back to the page with a clear message instead of an error or an empty file.
  • Low memory. Very large exports can be processed in chunks.

Use it when visitors download large lists (transactions, orders, logs, reports) as Excel, and the Views Data Export batch is too slow or the standard export runs out of memory.

Post-Installation

  1. Install the module with Composer, which also installs OpenSpout: composer require drupal/views_data_export_openspout. Then enable it.
  2. Edit a View that has a Data export display and select that display.
  3. Under Format, click Fast XLSX export: Off and check Stream this export to .xlsx with OpenSpout.
  4. Optional settings:
    • Maximum rows: larger exports are refused with a message.
    • Process rows in chunks of: leave at 0 to process all rows at once, exactly like Views. Set it, for example to 5000, for very large exports to keep memory low. In chunk mode, result hooks see one chunk at a time, so don't use it if a module needs the whole result (totals, re-sorting).
  5. Save the View. The export link now downloads the .xlsx directly, with a progress bar.

Notes:

  • The output is always a single-sheet .xlsx, whatever formats the display's style lists.
  • The file name comes from the display's Filename setting (tokens supported). Characters that Windows does not allow in file names are replaced.
  • The export runs in a single request, so very large exports are limited by PHP's max_execution_time.
  • Custom export links (not rendered by Views Data Export) can use the progress bar too: add the data-openspout-export attribute and attach the views_data_export_openspout/progress library.

Additional Requirements

  • Drupal 10.3 or later, or Drupal 11.
  • PHP 8.3 or later (required by OpenSpout 4).
  • Views Data Export.
  • The OpenSpout library (openspout/openspout ^4), installed by Composer.
  • XLS Serialization: you need it to create xlsx Data export displays in Views Data Export in the first place. This module then replaces its output on the displays you enable.

Similar projects

Supporting this Module

Bug reports, patches and merge requests in the issue queue are the best way to help.

Community Documentation

See the README.md included with the module.

Supporting organizations: 
Initial building, ongoing maintenance and development

Project information

Releases