CSV export showing html markup

(6 posts) (2 voices)
  1. nsepetys, Member

    Hello myDBR Representative,

    How are you doing? I am noticing an issue that happens when a report, with html included in the column, will reveal the html code for CSV exports. Below is an example:

    SELECT CONCAT('dbr.purehtml:<font color="darkblue">', username, '') AS 'User Name[username]' FROM testtable WHERE userid = @userid;

    Output should just be the username for CSV but it instead prints "<font color="darkblue">Bob Smith". The view in the web client, PDF and xlsx export seem to both be working fine. Both the web client and PDF show the styling while the xlsx export masks/hides the html code as expected. Any chance you guys can look into this?

    Thanks,
    Noah

    PS: Appears that the "CODE" object for this forum is not working as I would expect either. It is stripping the "</a[right arrow][left arrow]/font>" from my query above. But I think you guys got the idea anyway.

  2. myDBR Team, Key Master

    Hi,
    instead of using old deprecated font-tag (not part of HTML5) and combining data with html code, you are better off if you use dbr.colstyle / dbr.colclass itself separating the data and the formatting. The CSV export is really inteded for data transfer and does not try ty strip out HTML code from the data.

    select 'dbr.colstyle', 'title', '[color:darkblue]';
    
    select username 'User Name[username]'
    from testtable
    where userid = v_userid;

    --
    myDBR Team

  3. nsepetys, Member

    There is much more involved than font styling in the actual code. The example I provided is just a simple fleshed out case. I have many other procs/reports that use this "dbr.purehtml" command so it'd be helpful if this was fixed. Can you help?

  4. myDBR Team, Key Master

    In order to safely remove tags from a string you will need a full featured HTML parser and it still is prone to errors. As CSV exports are normally used for data transfer, this may cause problems, hence the recommendation not relying on HTML code with your data.

    We can add basic strip_tags functionality as an option to CSV exports. This should be ok for most cases, but as said, you will get best results if you do not mix data with formatting.

    --
    myDBR Team

  5. myDBR Team, Key Master

    You can use the

    select 'dbr.export.options', 'csv.strip_tags';

    to make html code to be stripped from the CSV export. Note that this feature uses PHP's strip_tags with it's restrictions (does not actually parse the HTML properly).

    --
    myDBR Team

  6. nsepetys, Member

    Thank you for the new option to remove the tags. I will try and implement a forward facing policy to conditionalize dynamic html output for future reports.


Reply

You must log in to post.