I have a rad grid and I am trying to export to word. I have few issue with it
1. I am able to export the grid and would like to add some extra content at the end of the document. I have tried below code but the html is coming at the top of the document but I would like to get the content at the end of the document.
protected void alllGrid_Exporting(object sender, GridExportingArgs e)
{
if (e.ExportType == ExportType.Word)
{
// this is for trying orientation landscape
e.ExportOutput = e.ExportOutput.Replace("<
body
>", "<
body
><
div
class
=
WordSection1
>");
e.ExportOutput = e.ExportOutput.Replace("</
body
>", "</
div
></
body
>");
string css = "<
style
> table @page{ mso-page-orientation:landscape;}</
style
>";
StringBuilder pageBrk = new StringBuilder();
// this is for page break
pageBrk.Append("<
br
clear
=
'all'
style
=
'mso-special-character: line-break; page-break-before: always'
/>");
pageBrk.Append(css);
// this actual html content which is rendering properly but at the top of the page
var customHTML = AdHocFilterSummary().Append(pageBrk);
e.ExportOutput = e.ExportOutput.Replace("<
body
>", "<
body
>" + customHTML);
}
}
2. I am trying to do orientation as landscape but I am not able to make it work. I have used the below code given in one of the forums but couldn't make it work. Am I missing something here?
protected void alllGrid_HTMLExporting(object sender, GridHTMLExportingEventArgs e)
{
e.Styles.Append("th { text-align:center; font-color:green; }");
if (Response.ContentType.Contains("excel"))
{
e.Styles.Append("
<!--table @page { mso-page-orientation:landscape;} -->
");
e.XmlOptions = "<
xml
><
x:ExcelWorkbook
>" +
"<
x:ExcelWorksheets
><
x:ExcelWorksheet
><
x:WorksheetOptions
>" +
"<
x:Print
><
x:ValidPrinterInfo
/></
x:Print
>" +
"</
x:WorksheetOptions
></
x:ExcelWorksheet
></
x:ExcelWorksheets
>" +
"</
x:ExcelWorkbook
></
xml
>";
}
else
{
e.Styles.Append("<!-- @page WordSection1 { size: 297mm 210mm; margin:1.0in 2.0in 1.0in 2.0in; }" +
"div.WordSection1 {page:WordSection1;} -->");
}
}
3. I am trying to get the same thing on excel too. No matter what i do, I am not getting anything on Excel. I am using ExcelML format. Is there any special way to do it?
Thanks.