jQuery UI Widgets Forums Grid Remove html tags when exporting to excel

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 9 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Remove html tags when exporting to excel #63870

    sadegh
    Participant

    Hi,

    I am trying to export data to excel from a jqxGrid, however I have cell which displays a number as a link, when I export the sheet the number will be exported as this <"a" href="#">23321</"a">, how can I remove this html tag when I am exporting.

    Thanks,

    • This topic was modified 9 years, 5 months ago by  sadegh.
    • This topic was modified 9 years, 5 months ago by  sadegh.
    • This topic was modified 9 years, 5 months ago by  sadegh.
    Remove html tags when exporting to excel #63891

    Dimitar
    Participant

    Hello sadegh,

    We do not experience such an issue. Please check out the following example and make sure you are using the latest version of jQWidgets (3.6.0):

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.export.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.export.js"></script>
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                // prepare the data
                var url = "../sampledata/feed.xml";
    
                var source =
                {
                    datatype: "xml",
                    datafields: [
                        { name: 'title', type: 'string' },
                        { name: 'link', type: 'string' },
                        { name: 'pubDate', type: 'date' },
                        { name: 'creator', map: 'dc\\:creator', type: 'string' },
                   ],
                    root: "channel",
                    record: "item",
                    url: url
                };
    
                var linkrenderer = function (row, column, value) {
                    if (value.indexOf('#') != -1) {
                        value = value.substring(0, value.indexOf('#'));
                    }
                    var format = { target: '"_blank"' };
                    var html = $.jqx.dataFormat.formatlink(value, format);
                    return html;
                }
                var dataAdapter = new $.jqx.dataAdapter(source);
    
                // Create jqxGrid.
                $("#jqxgrid").jqxGrid(
                {
                    width: 850,
                    source: dataAdapter,
                    pageable: true,
                    autoheight: true,
                    columns: [
                      { text: 'Link', datafield: 'link', width: 550, cellsrenderer: linkrenderer },
                      { text: 'Title', datafield: 'title', width: 200 },
                      { text: 'Publish Date', datafield: 'pubDate', width: 250, cellsformat: "D" },
                      { text: 'Creator', datafield: 'creator', width: 200 }
                   ]
                });
    
                $("#excelExport").click(function () {
                    $("#jqxgrid").jqxGrid('exportdata', 'xls', 'jqxGrid');
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
            <div id="jqxgrid">
            </div>
            <input type="button" value="Export to Excel" id='excelExport' />
        </div>
    </body>
    </html>

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.