Export Multiple paragraphs (html) inside a single excel cell

4 posts, 0 answers
  1. Alok
    Alok avatar
    39 posts
    Member since:
    Feb 2009

    Posted 15 Apr 2013 Link to this post

    Have a scenario, where a form includes dropdown box and RadEditor.

    Once the user enters the Audit Status and Audit Objectives. The data is saved in the database. And from the database it is exported to the excel sheet. But since Audit Objectives field is a RadEditor control, the user enters the formatted data, which includes html tags like <p>, <span>, <br> etc.
    When the data is exported to excel sheet, it does not store the entire data(audit objectives) in one cell, rather where it finds the <p>, <div> etc tags it breaks the data and copies the data in the new cell. Like the image below.

    The cell B2 should store the entire text Paragraph line1 and line2 (as formatted in the Rad Editior).
    The Html stored in the db is
    <table>
            <tr>
                <td>
                    <p style="mso-data-placement: same-cell;">
                        Paragraph</p>
                    <span style="margin: 0px 0px 12px 0px; text-align: left; text-indent: 0pt; padding: 0px 0px 0px 0px;
                        mso-data-placement: same-cell;"><span style="font-family: 'Verdana'; font-style: Normal;
                            font-weight: normal; font-size: 16px; color: #000000;">line1</span></span>
                    <br style="mso-data-placement: same-cell;">/>
                    <span style="margin: 0px 0px 12px 0px; text-align: left; text-indent: 0pt; padding: 0px 0px 0px 0px;
                        mso-data-placement: same-cell;"><span style="font-family: 'Verdana'; font-style: Normal;
                            font-weight: normal; font-size: 16px; color: #CA6919;">line2</span> </span>
                </td>
            </tr>
        </table>
    Please Note : Am exporting the excel data using JAVASCRIPT.

    Please suggest.
    ASAP!!
  2. Alok
    Alok avatar
    39 posts
    Member since:
    Feb 2009

    Posted 15 Apr 2013 Link to this post

    Its an URGENT!! issue.
    Waiting for a prompt reply.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sandeep
    Sandeep avatar
    22 posts
    Member since:
    Apr 2013

    Posted 16 Apr 2013 Link to this post

    Hi All,

    I am also facing similar kind of problem. Could any body help on this.

    Regards,
    Sandeep
  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 18 Apr 2013 Link to this post

    Hi guys,

    Note that the way the HTML is exported to the Excel document depends on your export implementation. There is an approach that you can use to strip particular tags from the HTML in the content of the RadEditor that should help you achieve the desired result. You can check it in the following code sample:
    <script type="text/javascript">
        function OnClientLoad(editor, args) {
            editor.get_filtersManager().add(new AllowedTagsFilter());
        }
        AllowedTagsFilter = function () {
            AllowedTagsFilter.initializeBase(this);
            this.set_isDom(false);
            this.set_enabled(true);
            this.set_name("AllowedTagsFilter");
            this.set_description("Strip the unwanted tags from RadEditor");
        }
        AllowedTagsFilter.prototype =
        {
            getHtmlContent: function (content) {
                return this._removeHtmlTags(content);
            },
            getDesignContent: function (content) {
                return this._removeHtmlTags(content);
            },
            _removeHtmlTags: function (initContent) {
                var cleanContent;
                //Perform necessary REGEX replacement to remove unsupported HTML tags
                //Supported HTML tags: FONT, STRONG, B, EM, I, U, A, OL, UL, LI, DIV, SPAN, P, BR, CENTER
     
                //Following REGEX will remove all HTML tags EXCEPT those explicitly listed
                cleanContent = initContent.replace(new RegExp("<(?!\/?(font|strong|b|em|(i(?!mg))|u|a|ol|ul|li|div|span|p|br|center)(?=>|\s?.*>))\/?.*?>", "ig"), "");
                return cleanContent;
            }
        }
        AllowedTagsFilter.registerClass('AllowedTagsFilter', Telerik.Web.UI.Editor.Filter);
    </script>
    <telerik:RadEditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1">
        <Content>sample content <strong>test</strong> <br/> test</Content>
    </telerik:RadEditor>

    Regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top