There are few issues I faced with XLS Data export and batch.

1. Empty file pre-created on first step of batch and then could not be read: "Unable to identify a reader for this file", because file doesn't contain xls headers.

Proposed solution: for xls(x) create empty spreadsheet object and save it into file instead of empty string.

2. If point 1 is solved, there are another issue that data of first batch operation is not stored into initialized file, so we loose header and first N rows (N - batch limit you configured).

Propesed solution: Remove condition by batch progress to write data into previous file, because before it wasn't written anywhere.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kiseleva.t created an issue. See original summary.

kiseleva.t’s picture

Status: Needs work » Needs review
StatusFileSize
new2.65 KB
kiseleva.t’s picture

Patch #4 for release 8.x-1.1

punamshelke’s picture

Added Patch #4 for release 8.x-1.3

Status: Needs review » Needs work

The last submitted patch, 5: views_data_export-xls-batch-3277334-5.patch, failed testing. View results

punamshelke’s picture

StatusFileSize
new2.24 KB
realityloop’s picture

Tried #7 and still getting error

Drupal 10.2.2

An error has occurred.
Continue to the error page

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=150&op=do_nojs&op=do
StatusText: error
ResponseText: The website encountered an unexpected error. Try again later.PhpOffice\PhpSpreadsheet\Reader\Exception: Unable to identify a reader for this file in PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile() (line 172 of /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php). PhpOffice\PhpSpreadsheet\IOFactory::load('/var/www/html/web/sites/default/files/views_data_export/user_admin_people_data_export_1/1-1706833150/.xls') (Line: 849)
Drupal\views_data_export\Plugin\views\display\DataExport::processBatch('user_admin_people', 'data_export_1', Array, Array, 20174, Array, '/', Array) (Line: 296)
_batch_process() (Line: 138)
_batch_do() (Line: 94)
_batch_page(Object) (Line: 52)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 54)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 41)
Drupal\ip_login\StackMiddleware\IpLoginMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 78)
Drupal\ip_login\StackMiddleware\EarlyIpLoginMiddleware->handle(Object, 1, 1) (Line: 270)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

jawidos’s picture

I just had the same problem and after searching some more i found the problem.
As mentioned here (https://github.com/PHPOffice/PhpSpreadsheet/issues/3930) PhpSpreadsheet function setCellValueByColumnAndRow was deprecated and is removed in 2.0

So i just replaced that funtion with the new one and it works again.
I il add the patch for anyone who needs it.

chetananemade’s picture

Hi,
The patch in #7 worked well for us with Drupal 10.2 and Views_data_export 1.4.
However, after upgrading to Drupal 10.3 and Views_data_export 1.5, we have updated the patch in #7 to make it compatible with the new versions.

The patch in #9 is already included in Views_data_export 1.5.

steven jones’s picture

@chetananemade thanks for the updated patch. We should try to get this into a MR instead of using patches.

jhedstrom changed the visibility of the branch 3277334-xls-batch-doesnt to hidden.

jhedstrom’s picture

Status: Needs work » Needs review
steven jones’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

@jhedstrom thanks for the MR I feel like this is the sort of thing that really should have a test. We have a test for CSV exports, but not for XLS ones, but we do include the module for testing etc. We should probably have a test for this sort of thing so that we don't introduce regressions etc.

I think we could either add another test case to the existing class, or have a new class for testing XLS stuff specifically, don't mind.

realityloop’s picture

Re-rolled for 1.8