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

Insert Print Page Break in Excel (HTML)?

2 Answers 229 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 23 Jan 2015, 01:42 AM
Is there a way to force a page-break into an Excel (HTML) export file - at a row of my choosing?  I can't find anything in the documentation about page breaks - and the forum search also turned up nothing for me.

2 Answers, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 25 Jan 2015, 05:13 PM
Doing some testing in Excel - it looks like it uses a <tr style="page-break-before: always">.  Oddly when I insert this rule in the data before going to Excel - it gets stripped or ignored.  When I save the Excel doc as HTML so I can view it - the style is gone.  

Have anyone got this working?
0
Kostadin
Telerik team
answered on 27 Jan 2015, 02:55 PM
Hi Dan,

A possible solution is to apply the following XML Options. 
protected void RadGrid1_HTMLExporting(object sender, Telerik.Web.UI.GridHTMLExportingEventArgs e)
{
    e.XmlOptions = @"<xml>
                <x:ExcelWorkbook>
                  <x:ExcelWorksheets>
                    <x:ExcelWorksheet>
                      <x:WorksheetOptions>
                        <x:Print>
                        </x:Print>
                      </x:WorksheetOptions>
                      <x:PageBreaks>
                        <x:RowBreaks>
                        <x:RowBreak><x:Row>3</x:Row></x:RowBreak>
                        <x:RowBreak><x:Row>5</x:Row></x:RowBreak>
                        <x:RowBreak><x:Row>7</x:Row></x:RowBreak>
                        <x:RowBreak><x:Row>10</x:Row></x:RowBreak>
                        </x:RowBreaks>
                      </x:PageBreaks>
                    </x:ExcelWorksheet>
                  </x:ExcelWorksheets>
                </x:ExcelWorkbook>
             </xml>";
}

I also noticed that we did not add the page breaks in our documentation so I will update it with this option as well.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or