Hello,

I've noticed that while exporting a view display as XLS, if some column has list items in it (< li>), then these items would occupy a different row, instead of being rendered together in the same cell.

To fix this, I simply replaced all instances of < li> to "&#10", which is the line feed character used to insert multiple lines in the same cell.

I've attached the generated patch.

Comments

caminadaf’s picture

Issue summary: View changes
StatusFileSize
new467 bytes
caminadaf’s picture

Status: Active » Needs review
uv516’s picture

I have tried this, but in my MS Excel (2007) it doesn't works.

Anonymous’s picture

StatusFileSize
new517 bytes

This might be slightly off-topic, but I had a similar problem with <br> tags (being output as separate rows). I made the attached patch, based off the one above, that converts <br> tags to new lines instead.

The problem with converting <li> tags to new lines is that the <ul>/<ol> tags are left there, which doesn't seem right. I also had a problem with extra new lines being added between fields...
You may be able to use this patch instead of the above one if you change any multi-valued fields in views from displaying as an (un)ordered list to being separated by the <br> tag.

Anonymous’s picture

Status: Needs review » Needs work

Actually, it turns out my patch doesn't work in Microsoft/Windows either (works in Libre Office on Linux though)...

phily’s picture

Status: Needs work » Needs review
StatusFileSize
new556 bytes

The problem with <br> tag in Excel is that it adds a new row, not a new line inside the same cell.
In order to add new line and stay in the same cell, the tag to add is <br style="mso-data-placement:same-cell;" />

So, in patch #4, the line

+ $output = preg_replace('/<\/?(br) ?.*?>/', "&#10;", $output); // replace 'br' tags with a new line character

shoud be replaced by

+ $output = preg_replace('/<\/?(br) ?.*?>/', "<br style=\"mso-data-placement:same-cell;\" />", $output); // replace 'br' tags with a new line character

I've tested it with Excel 2010 for Windows and Excel 16.13 for Mac with success.
But be warned it will add new rows in LibreOffice Calc unless the file has been saved from Excel before...

Updated patch is attached.

andras_szilagyi’s picture

Patch #6 works in office 365 Excell, Patch #1 does not.
I suggest a new patch that resolves both li and br.

andras_szilagyi’s picture

StatusFileSize
new633 bytes

Here is the new patch which solves both issues in Excell office 365.

kris77’s picture

Patch in #8 works fine for me.

Thanks @Andras_Szilagyi

steven jones’s picture

Status: Needs review » Closed (won't fix)

Sorry for the lack of attention to your issue, please accept my apologies.

Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.

As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.

If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, then please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.

Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated.
The Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)