Cells with HTML value in Excel Export?

9 posts, 0 answers
  1. Brian Roth
    Brian Roth avatar
    139 posts
    Member since:
    Oct 2005

    Posted 05 Dec 2014 Link to this post

    I have a few cells in a grid where the value contains HTML strings.   As an example, we bold part of a string like "This item costs <b>$100<b>".  When we export to Excel, that cell displays the full HTML string.  Do you know if there's a way through the api that we can tell that cell to render as HTML so that the <b> tags don't show up and the text is properly bolded?  Thanks!

    Regards,
    Brian
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1443 posts

    Posted 09 Dec 2014 Link to this post

    Hi Brian,

    Exporting cells containing HTML is not supported, as mentioned in the documentation. I would recommend checking this example, illustrating a possible workaround using the excelExport event.

    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Brian Roth
    Brian Roth avatar
    139 posts
    Member since:
    Oct 2005

    Posted 10 Dec 2014 in reply to Alexander Popov Link to this post

    Hi Alexander,

    Thanks for the reply.  This was helpful.  I still haven't figured out a way to only bold part of a value, but I'll keep looking.

    Regards,
    Brian
  4. Frank
    Frank avatar
    1 posts
    Member since:
    Aug 2017

    Posted 17 Oct 2017 in reply to Alexander Popov Link to this post

    Hi, quick question, is the above still not supported?

    we have the same situation. there are cells with html tags that are showing nicely in grid but for Excel export we have to remove the tags. except that user needs to see part of the cell's text in bold. 

    Regards,

    Frank J.

     

  5. Stefan
    Admin
    Stefan avatar
    2786 posts

    Posted 19 Oct 2017 Link to this post

    Hello, Frank,

    This can be achieved using custom logic on the excelExport event as suggested.

    We have new examples for taking only the text from the HTML tags. It is for the footer template, but the same approach is valid for the cells as well:

    https://docs.telerik.com/kendo-ui/knowledge-base/export-only-the-text-from-the-grid-cell-which-contains-html

    Also, the bold style can be added using the custom styles:

    https://docs.telerik.com/kendo-ui/framework/excel/appearance#configuration-options

    I hope this is helpful.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. John
    John avatar
    2 posts
    Member since:
    Dec 2019

    Posted 30 Dec 2019 in reply to Stefan Link to this post

    https://docs.telerik.com/kendo-ui/knowledge-base/export-only-the-text-from-the-grid-cell-which-contains-html

    Hi,

    I also have the same issue, my grid display paragraph content with html tags. if part of paragraph bold, it display correctly in grid and also in export PDF. but not in export excel.

     { field: "UnitPrice", title: "Price", template: '<b>Price</b>: #: kendo.format("{0:c}", UnitPrice)#' }

    the above link only give the template value. even, if i bold the Price text, it display correctly with bold in grid but in export excel , it display as <b>Price:</b>.

     

  7. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    967 posts

    Posted 30 Dec 2019 Link to this post

    Hi, John,

    The article that you reference shows how to remove arbitrary HTML from the XML which could otherwise break it. It seems that you would like to do the opposite - show the column in the excel file as bold text, please correct me if I am wrong.

    To better understand what goes on - the grid is a UI component which visualizes the data in its data source. The excel export does a similar thing - it exports the underlying data, it does not process arbitrary content in templates:

    https://docs.telerik.com/kendo-ui/controls/data-management/grid/export/excel-export#known-limitations

    The formats that are used in the workbook, follow the Microsoft formats and I did not find a way to include bold text within it:

    https://support.office.com/en-us/article/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68

    You could use the excelExport event to add another Column and make the Price text bold by using the sheets.rows.cells.bold property or you could bold the entire value:

    https://dojo.telerik.com/@bubblemaster/EkOSOdix/2

      excelExport: function(e) {
        var sheet = e.workbook.sheets[0];
        for (var i = 1; i < sheet.rows.length; i++) {
          var row = sheet.rows[i];
          row.cells[1].format = ' " Price" $0.00;'
          row.cells[1].bold = true;
        }
      }

    Let me know in case you have further questions.

    Kind Regards,
    Alex Hajigeorgieva
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  8. John
    John avatar
    2 posts
    Member since:
    Dec 2019

    Posted 30 Dec 2019 in reply to Alex Hajigeorgieva Link to this post

    Hi,

    Thanks for the reply.

    But the cells.bold property is bold the entire cell content.

    But we dont need that. For example, my cell contains line like below:

    "Oats’ momentum in Greece is bold and growing. Today, thanks to Quaker’s strong brand and consistent strategy, many new products entering the market contain oats and try to communicate vocally on the goodness of oats."

     

    Here, I want to bold the text Oats and Quakers in gird and also in export excel.

    so my content would be as below

    "<b>Oats’<b> momentum in Greece is bold and growing. Today, thanks to <b>Quaker’s</b> strong brand and consistent strategy, many new products entering the market contain oats and try to communicate vocally on the goodness of oats."

    This displaying correctly with bold property in grid as below

    "Oats’ momentum in Greece is bold and growing. Today, thanks to Quaker’s strong brand and consistent strategy, many new products entering the market contain oats and try to communicate vocally on the goodness of oats."

    but in excel, it display as below

    "<b>Oats’<b> momentum in Greece is bold and growing. Today, thanks to <b>Quaker’s</b> strong brand and consistent strategy, many new products entering the market contain oats and try to communicate vocally on the goodness of oats.".

    So I want in excel how it is in grid. could you please provide any solution for this?

  9. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    967 posts

    Posted 31 Dec 2019 Link to this post

    Hi, John,

    I understand the requirement is to bold part of the cell but I did not find a way that Microsoft Excel have allowed for this to be configured:

    https://support.office.com/en-us/article/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68

    The format of the cell is proprietary to the Excel cell and it is Excel that interprets how to show the cell. If you can find a way to do that with Excel custom numeric formatting - i.e bold part of the cell, then that should be used to pass to the Kendo UI Workbook cell.

    If Microsoft did not implement such conditional custom formatting, then the alternative would be to insert a separate column with the bold text and next to it have the regular text:

    Here is a test example for your reference:

    https://dojo.telerik.com/EMeKetEr/2

    Kind Regards,
    Alex Hajigeorgieva
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top