I'm attaching patch to vbo_export, which adds export to word functionality.

How it works:

  1. Renders every entity in default view mode.
  2. Export data to *.doc file as HTML table (two columns - first - label, second - data)
  3. In configuration, you can set maximum number of rows, which can be exported at once. This is to prevent memory limit error. If you have complex entity types, it may fail with bigger number of rows. Our tests shows, that limit is 5000 - 10000 items, depending how complex entities are.
  4. If user will select more rows than defined limit, confirmation form will be displayed. If user will continue, only first LIMIT selected items will be exported. (e.g. if 4000 will be set as limit, only first 4000 selected entities will be exported).

For export to word, extra patch is required for views bulk operations. See: https://www.drupal.org/project/views_bulk_operations/issues/3075992

Issue fork vbo_export-3075993

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

gugalamaciek created an issue. See original summary.

gugalamaciek’s picture

StatusFileSize
new22.23 KB

Patch for version 3.2

gugalamaciek’s picture

StatusFileSize
new22.48 KB
new2.08 KB

Improve multilanguage support

graber’s picture

Hi Maciek, good stuff :) can you get some friend to review this as well? I'm terribly busy recently and don't use the module on any of my projects currently :(

graber’s picture

Status: Active » Needs review
bezig’s picture

Hello i got an error.
An AJAX HTTP error has occurred.
Received HTTP Code: 500
Debug information follows.
Path: /batch?Id=139&op=do_nojs&op=do
Status Text: 500 Service Unavailable (with message)
Response Text: An unexpected error occurred on the site. Please try again later.

Message DomainException: When a #lazy_builder callback is specified, no properties can exist; all properties must be generated by the #lazy_builder callback. You specified the following properties: #label_display. in Drupal\Core\Render\Renderer->doRender() (line 336 of D:\OpenServer\domains\tst\core\lib\Drupal\Core\Render\Renderer.php).

commented out the line, everything worked.
where is the mistake?

  protected function renderField(EntityInterface $entity, array $pre_render) {
   /** $pre_render['#label_display'] = 'hidden';*/
    return (string) $this->renderer->render($pre_render);
  }
bezig’s picture

Images are not exported
The generated document contains only relative links to images.
Also with export to xls.
Can this be configured somehow?

falc0’s picture

Version: 8.x-3.x-dev » 4.0.0
StatusFileSize
new22.4 KB

Patch for version 4.0.0

graber’s picture

Status: Needs review » Needs work

Looks good but noticed a few things:
vbo_export.config shouldn't be global here, an action can have preliminary configuration per view (or per display), see https://www.drupal.org/docs/8/modules/views-bulk-operations-vbo/configur.... This'll give site builders better flexibility and will not require an extra route.

+ * @Action(
+ *   id = "vbo_export_generate_doc_action",
+ *   label = @Translation("Generate doc from selected view results"),
+ *   type = "",
+ *   pass_context = TRUE,
+ *   pass_view = TRUE,
/// Not needed, confirm_form_route_name is enough. ///
+ *   confirm = TRUE,
+ *   confirm_form_route_name = "vbo_export.word_export_confirm"
+ * )

I'd also call the parent method in ConfirmWordAction:: buildForm() and modify the output.

rp7’s picture

StatusFileSize
new22.4 KB

Noticed an issue in #8, the vbo-export-content-doc-wrapper.html.twig template was no longer being used (leading to encoding issues for special characters when opening export Word docs on Windows).

Comments in #9 still need to be addressed, though.

rp7’s picture

StatusFileSize
new23.05 KB

Added config schema definition for the new action plugin.

Comments in #9 still need to be addressed, though.

rp7’s picture

StatusFileSize
new23.18 KB

Apparently a new word_limit global vbo_export configuration property is added as well. Providing schema definition for this as well.

Comments in #9 still need to be addressed, though.

rp7’s picture

StatusFileSize
new23.13 KB

Rerolled against 4.x

Comments in #9 still need to be addressed, though.

rp7’s picture

StatusFileSize
new23.05 KB

4.x reroll attempt #2

graber’s picture

Version: 4.0.0 » 4.x-dev

Same review remarks apply as in #9:
Please implement one or both of buildConfigurationForm, buildPreConfigurationForm in your the class instead of creating global config and adding those 2 form classes separately.

falc0’s picture

StatusFileSize
new25.55 KB

My attempt to fix rendering nested groups

I skipped comments in #9 for now.

falc0’s picture

StatusFileSize
new26.66 KB

Fixed labels not showing in nested groups.

rp7’s picture

StatusFileSize
new26.6 KB

Fixed deprecation notice: Deprecated function: Creation of dynamic property Drupal\\vbo_export\\Plugin\\Action\\VboExportDoc::$renderer is deprecated in Drupal\\vbo_export\\Plugin\\Action\\VboExportDoc->__construct().

astonvictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Needs work » Needs review

Hi there,

Prepared a new MR with a plugin to export data as a doc file. For exporting data, it uses phpoffice/phpword package.

Please, check if it works for you.

p.s. I didn't update the requirements hook because the package doesn't have a changelog file from the 1.2.0 version. And there is no sense to use 1.1.0 version because it uses the deprecated utf8_encode() function.
thanks in advance

astonvictor’s picture

Version: 4.x-dev » 4.2.x-dev
Status: Needs review » Fixed

fixed in a new 4.2.x branch
thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.