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

Header with two lines

2 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
Iron
Veteran
David asked on 21 Jul 2016, 01:30 PM

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 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 25 Jul 2016, 10:19 AM
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.
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 25 Jul 2016, 01:35 PM

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

Tags
Grid
Asked by
David
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Pavlina
Telerik team
David
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or