Dev 2011-Jul-01 (1309567725)

Why is all HTML removed from export and no specific settings to change this? This module isn't as effective if we can't retrieve raw data. Same goes for extra spaces and returns.

#34 views_data_export-1224894-keep-html-option-with-tests.patch5.36 KBSteven Jones
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1224894-keep-html-option-with-tests.patch. Unable to apply patch. See the log in the details link for more information. View
#22 views_data_export-1224894-22-D6.patch1.86 KBCottser
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es). View
#10 html_in_csv-1224894-10.patch1.87 KBidflood
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch html_in_csv-1224894-10.patch. Unable to apply patch. See the log in the details link for more information. View
Members fund testing for the Drupal project. Drupal Association Learn more


okletsgo’s picture

seems like CSV is only effected?

Steven Jones’s picture

Title: Text HTML » Add an option to not strip tags from CSV export
Version: 6.x-2.x-dev » 7.x-3.x-dev
Component: User interface » Code
Category: bug » feature
Rade’s picture


globalcrafts’s picture

Also need a way to get full HTML exported via a csv option.

drupleg’s picture

While it would be nice to have this as an interface option - you can achieve this by editing a file to remove the php strip_tags() function:

edit line 480 of this file views_data_export/theme/

change $output = decode_entities(strip_tags($value));
to $output = decode_entities($value);

Now your CSV rows will be output with HTML.

That's the line number as of my post in 7.x-3.x-dev, however if line numbers change within the file just look for this section of code to change the strip_entities bit in the rows only:

  // Format row values.
  foreach ($vars['themed_rows'] as $i => $values) {
    foreach ($values as $j => $value) {
      $output = decode_entities(strip_tags($value));
      if (!empty($vars['options']['trim'])) {
        $output = trim($output);
ckng’s picture

Status: Active » Closed (works as designed)

#5 is evil - don't hack module!

There are already multiple preprocess theme functions available, either implement the hook in your custom module or theme.

- OR -

drupleg’s picture

ckng, I can't speak for the other users here, but for myself - I don't know how to create modules or template_preprocess functions. I did the only thing I knew how to do - change some basic php. I'm just learning the "Drupal Way" and it would have never occurred to me that the correct way to accomplish this would be a) creating a separate module to modify this module, or b) creating some function in the theme layer... what if I change my theme? I just want some CSV output.

If you would kindly show us the proper way to have added this functionality somehow with a copy/paste code example and instructions, please do. If not then I'll have to stick with my evil hacked module.

-- Tony

idflood’s picture

Status: Closed (works as designed) » Active

Sorry to reopen this issue, but I feel it can be a common task. The clean solution right now it to copy these two "long" 60 lines functions to only change 2 lines, or did I miss something?

So if I can come up with a patch that adds an option to the csv export to keep html tag has it any chance to be accepted?

Steven Jones’s picture

Patches would be most welcome, and I'd like to get this feature in.

idflood’s picture

Status: Active » Needs review
1.87 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch html_in_csv-1224894-10.patch. Unable to apply patch. See the log in the details link for more information. View

Here is a quick patch that fixed my specific issue. It simply adds a 'Keep HTML tags.' option to the csv export style.

Steven Jones’s picture

Status: Needs review » Reviewed & tested by the community

An initial scan of the patch looks good to me.

mxh’s picture

comment to #5: It's not recommended to hack source code. Please remove #5 or mark it as not recommended. (@brentratliff & drupleg: sorry for the previous harsh post, I appreciate a lot that you spend the time to investigate on this issue, thank you.)

Steven Jones: Patch from #10 worked for me on D7.12 and Views 7.x-3.1.

I'd love it to see this being commited to upcoming Views Data Export releases.


drupleg’s picture

idflood - thank you for the patch, it worked well for me, and helped me learn something useful.

Maxelli, last I checked the saying was "don't hack Core", the whole point of source code is to explore and hack it. This module is not Drupal Core, and it's not something I am contributing back to the community, it's a -dev version on my dev site to do whatever I want with - my evil hack worked very well for my specific use case, and I thought it was worth sharing with the others on this post (which had gone 7 months without any other suggestion about how to get full HTML out of this module). Feel free to remove my previous post, and pardon me for trying to help in the only way I knew how.

brentratliff’s picture

I don't see any reason to remove the post, that's a little extreme. Sometimes hacking a module is prudent, you just have to manage the patches yourself in the event of an upgrade. Pressflow hacks core and it powers most of the high performance sites including this one. In this case, there's certainly a more Drupal way to do it and a hack is not required, but this is open source and the dialog is how we learn. @drupleg is trying to help and being shafted for it. As a module maintainer, I appreciate any code contributions as they may lead to an eventual solution.

drupleg’s picture

Alrighty, we're all friends again! :) If idflood's patch looks good to Steven he'll roll it in to the module and close this issue. Thanks everyone!

erikwebb’s picture

Another confirmation here. Looks good and ready to get this into a release.

mxh’s picture

Could you please tell me if this is already commited? Can't see it in the release notes of 7.x-3.0-beta6. Thanks!

byrond’s picture

#10 works for me. I'm a little curious why keeping HTML tags isn't the default behavior (with possibly an option to strip), since tags can be removed from each field by views.

IT100’s picture

Make sure formatter isn't a link in output fields or #10 lets the output fields contain html tags... which isn't wanted in cvs. Also, an image field will contain ... tags, this lets feeds import fail, uncheck "show as link" selection and strip html tags in rewrite results so you are left with only the link to the file.

Download of <a%20href=""%20target="_blank"><a%20href="/content/url-path"></a></a> failed with code -1002
Cottser’s picture

Patch applies cleanly, works as described, and I was able to use Views to strip some of the tags as well. Still RTBC, thanks @idflood!

1mundus’s picture

Does anyone know what to do with 6.x version? Is this maybe commited in -dev versions?

Cottser’s picture

1.86 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es). View

Here's a patch against 6.x-2.x-dev that applies to 6.x-2.0-beta6 as well.

Zach Harkey’s picture

Confirm #10 works and I would argue that this is a great pretty critical addition to the module.

1mundus’s picture

#22 works for D6, thank you Cottser!

Steven Jones’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We're adding tests to the module, so this patch will also need some tests to get in. Sorry!

brephraim’s picture

Status: Needs work » Needs review

#10: html_in_csv-1224894-10.patch queued for re-testing.

Steven Jones’s picture

Status: Needs review » Needs work

Back to 'Needs work' for those tests.

brephraim’s picture

Sorry :)

wusel’s picture

Status: Needs work » Reviewed & tested by the community

I use:
Views 7.x-3.5+20-dev (2012-Oct-25)
Views data export 7.x-3.0-beta6+22-dev (2012-Oct-28)

I have tested patch at #10 to export an csv file.

It works very fine, if I want and I can drop this featcher, if I like. Famous!!!

Please import this patch very soon! Thank you very much.


idflood’s picture

Status: Reviewed & tested by the community » Needs work

Back to needs work since we need to add tests.

wusel’s picture

I think, if the user does not check the new option, then there is no difference than without this D7-patch.

So I can not understand, why this patch shall not be imported to the dev-version. Sorry!

The age of this issue is more than ONE year. The age of #10-patch is several month old and there are very many good comments and no test-data, which fails the test, which we can test.

I hope, you change you opinion.


mxh’s picture

@ wusel
I disagree. We need tests for this one. Maybe at the moment it works, but in upcoming new features and refactoring there could be overseen changes which could cause problems with this feature when we do not add tests.

wusel’s picture

I disagree! If the user does not check the new option, then there is no difference than without this D7-patch.

So I can not understand, why this patch shall not be imported to the dev-version soon. Sorry!
Then everybody can test and we get a better module.

Steven Jones’s picture

Status: Needs work » Needs review
5.36 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1224894-keep-html-option-with-tests.patch. Unable to apply patch. See the log in the details link for more information. View

Here's the patch from #10, with some tests.

Steven Jones’s picture

Version: 7.x-3.x-dev » 6.x-2.x-dev
Status: Needs review » Patch (to be ported)

Sweet, thanks everyone. This just needs to be backported to 6.x-2.x.

Steven Jones’s picture

Sorry, if that wasn't clear, I've pushed the patch into 7.x-3.x and added tests.

rootical’s picture

Greate job - also you could apply it to the 6th version of the module. Thanks a lot! I`ve patched my 6th version and`ve been able to migrate a lot of nodes with tags)

Cottser’s picture

@rootical - if you can post a patch for 6.x-2.x that would definitely help move this along :)

555kirill’s picture

Status: Patch (to be ported) » Needs review
Issue tags: -Needs tests

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

The last submitted patch, views_data_export-1224894-keep-html-option-with-tests.patch, failed testing.

Cottser’s picture

Status: Needs work » Patch (to be ported)

Patch from #34 needs to be backported to Drupal 6.

Here's the documentation on backporting core patches:

tomsolo’s picture

Status: Patch (to be ported) » Needs review

#10: html_in_csv-1224894-10.patch queued for re-testing.

Ryan258’s picture

Turns out this XLS export approach is a dead end. You'll find that <a> tags at the very least get stripped.

But at least there's always sql queries if you make a dump of the database.

To do that you can export a copy of the db, upload it somewhere safe and run queries against it. If you copy past the query from your dat export view you'll get results that can be exported as a .csv

Body content is found in the node > revisions table. You don't need to know that, but seeing it there is a good small step to explore how the db is structured and give you more of a whole picture of how drupal does what it does.

terikon’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev

#36 worked for me, but in my case it was not enough.
I use markdown filter, so body field stored in database differs from body field rendered to html.
I needed to export original value (which is stored in database column`field_revision_body`.`body_value`). Even though current dev version of Views data export enables html tags, it collects values after text filters applied on them.
This sandbox raw formatter project enables unfiltered output of a field in views, so value can be exported unaltered as it stored in database.

wooody’s picture

#22 works with me Drupal6 ... Thank you Cottser ..

chunty’s picture

Any chance we could have this option for text files as well. I need to dump the contents of a single field out to a text file and I don't want the HTML stripped


Heihachi88’s picture

Issue summary: View changes

Why this patch is not in the dev version of this module?

Notice. When using drush to generate file via command:

drush views-data-export view-name view-id file.csv

It won't generate any file because of HTML :(

veeray’s picture

#5 worked for me in d6. I am going to use like that on a temporary basis to get my content out of an old site.

veeray’s picture

#5 is working for me like a charm.

pal4life’s picture

I took the latest module 7.x-3.0-beta7 but this is still an issue, it still strips out all the html from the body field.
Also tried the patch in #10 with no success.


gowlj’s picture

any workaround for body with stripped out html?


Steven Jones’s picture

Version: 7.x-3.x-dev » 6.x-2.x-dev
Status: Needs review » Patch (to be ported)

This isn't an issue in 7.x-3.x

  • Steven Jones committed 1ca4bb3 on 7.x-4.x
    Issue #1224894 by Steven Jones: Added tests for option to not strip tags...
  • Steven Jones committed 93b2079 on 7.x-4.x authored by idflood
    Issue #1224894 by idflood: Added an option to not strip tags from CSV...
manoloka’s picture

Hi Steve,

You said "This isn't an issue in 7.x-3.x" yet I'm using 7.x-3.0-beta8 and YES it is the same issue. All html tags get stripped

Please explain

--- updated ----

Just uploaded de dev version and I can find the "keep html tags" option’s picture


Thanks for all the work in this thread. I've used the patch in #22 on 6x dev and I get HTML. However there's a problem. All the HTML exported isn't dealing with certain characters properly. Quotation marks, dashes, etc, all turn into gibberish. Does anyone know of a solution to this? I'm trying to export hundreds of nodes from my D6 site into my would love to know if anyone knows how to render the html properly on output. Thanks!

boabjohn’s picture

Hey there @manoloka,
Like you, I was totally baffled. Assume that by now you located the setting: it is (unfortunately) not provided on a per-field basis. So look in your Views: Format: Settings and you'll find an option to preserve HTML tags on all fields in the export. If that does not suit you'll need to be creative with the formatting of your fields when they are presented to Views for rendering.
Go well.

yuhao6066’s picture

It seems like no people care about xls format, after a bit check I found line 321 in
$vars['tbody'] = preg_replace('/<\/?(a|span) ?.*?>/', '', $output); // strip 'a' and 'span' tags
Why don't we add this "keep_html" feature to xls format? I think there's more practical use for hyper-link in xls file.

greggadsdon’s picture

Status: Patch (to be ported) » Closed (won't fix)

As Drupal 6 nears the end of its life and support period, the 6.x version of Views Data Export will not be supported either. To that end, this issue has been closed, and will not be resolved in the 6.x branch of Views Data Export.

If this issue is still relevant to 7.x branch of Views Data Export, then please re-open and move to a relevant 7.x version.

kalaiselvann’s picture

Comment #5
it's working for me

aniket.mohite88’s picture


I am using Drupal 7.56, Views 7.x-3.17 & Views Data Export 7.x-3.2.

For the export CSV, it now has the option to keep the HTML, in the Views, under Format (CSV File) Settings.