I have been trying to get the XLS exports to only export the headers of columns that are not empty, and I keep running into dead ends.

I started with the patch from #1646596: Support for "Hide if empty" field option (which has a bug in it), and added $vars['hide_empty_support'] = TRUE; to template_preprocess_views_data_export_msoffice_body(), but that did not give me the results I wanted. I then moved to the -dev version (which has the bug fixed), but it still doesn't work for XLS files.

The main problem is that the body data is not available when creating the header row, and the $vars['header_row'] variable is not available when creating the body data.

In views_data_export.theme.inc, when creating the $vars['header_row'] variable in the template_preprocess_views_data_export_msoffice_header() function (which is what becomes the header row of the XLS file), the $vars['view']->style_plugin->rendered_fields array that is used in _views_data_export_body_shared_preprocess() to check the fields' values does not exist. I found some similar data in $vars['view']->result->_field_data, but it isn't exactly the same, and the field IDs don't always match, especially for aliased fields.

When eliminating empty columns in _views_data_export_body_shared_preprocess(), where the data exists, the $vars['header_row'] variable is not available, and therefore, cannot be modified.

It's obvious to me that I'm either not in the right place or I'm doing it wrong, but I cannot figure that part out. Where or how can I make this happen?

Comments

steven jones’s picture

Status: Active » Closed (won't fix)

Sorry, but VDE just isn't designed to look at all the data in a single column and make decisions based on its contents, so this issue isn't ever going to get solved.