This is a migrated thread and some comments may be shown as answers.

Export Multiple paragraphs (html) inside a single excel cell

3 Answers 568 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Alok
Top achievements
Rank 2
Alok asked on 15 Apr 2013, 12:50 PM
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!!

3 Answers, 1 is accepted

Sort by
0
Alok
Top achievements
Rank 2
answered on 16 Apr 2013, 04:31 AM
Its an URGENT!! issue.
Waiting for a prompt reply.
0
Sandeep
Top achievements
Rank 1
answered on 16 Apr 2013, 07:22 AM
Hi All,

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

Regards,
Sandeep
0
Slav
Telerik team
answered on 18 Apr 2013, 09:47 AM
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.
Tags
Editor
Asked by
Alok
Top achievements
Rank 2
Answers by
Alok
Top achievements
Rank 2
Sandeep
Top achievements
Rank 1
Slav
Telerik team
Share this question
or