Header with two lines

3 posts, 0 answers
  1. David
    David avatar
    159 posts
    Member since:
    Mar 2014

    Posted 21 Jul Link to this post

    I created header with two lines by using <br/>. It looks fine, but during export to excel <br/> is visible. Here is the code example:

                       Dim ColumnNumeric As New GridNumericColumn()
                        grdResourceGrid.MasterTableView.Columns.Add(ColumnNumeric)
                        ColumnNumeric.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
                        ColumnNumeric.DataField = dr("ResourceTitle")
                        ColumnNumeric.HeaderText = dr("ResourceTitle") & "<br/>$" & dr("Rate")
                        ColumnNumeric.SortExpression = dr("ResourceTitle")
                        ColumnNumeric.HeaderStyle.HorizontalAlign = HorizontalAlign.Right
                        ColumnNumeric.ItemStyle.HorizontalAlign = HorizontalAlign.Right
                        ColumnNumeric.DataFormatString = "{0:N2}"

    I tried to solve it by adding additional header, but it didn't export at all. Code:

    Dim newHeaderItem As New GridHeaderItem(grdResourceGrid.MasterTableView, 0, 0)
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "1"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "2"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "3"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "4"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "Steve"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "Chandler"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "Naomi"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "1_Naomi"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "1_Steve"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "1_Chandler"})
            newHeaderItem.Cells.Add(New GridTableHeaderCell() With {.Text = "f"})

    Please recommend solution

     

  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 25 Jul Link to this post

    Hello,

    Did you try using the approach for line breaks provided in the article for HTML based export linked below?
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/word-and-excel-export/html-based-export#line-breaks

    It will allow you to move the text on the next line.

    Regards,
    Pavlina
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    159 posts
    Member since:
    Mar 2014

    Posted 25 Jul in reply to Pavlina Link to this post

    Hi Pavlina,

        Your post helped me indirectly. At first debugger didn't hit functions suggested in the link. After brief digging i realized that export has to be HTML to use ExportCellFormatting function. Wheni switched to HTML export, all started to work without any additional intervention.

    Thank you

    David

Back to Top