I am using the ExcelML format to export a grid and have a couple of questions regarding the formatting.
1. How can apply a border to the header row. I have looked at the following code that is in the documentation and added it to the
ExcelMLExportStylesCreated event but it gives me an error message Object reference not set to an instance of an object. on this line
- borderStyle.PositionType = DirectCast(i, PositionType)
Also I can't figure out how to apply the style to the header row.
Dim cstyle As New StyleElement("MyCustomStyle")
Dim borders As New BorderStylesCollection()
Dim borderStyle As BorderStyles
For i As Integer = 1 To 4
'four borders
borderStyle.PositionType = DirectCast(i, PositionType)
borderStyle.Color = System.Drawing.Color.Black
borderStyle.LineStyle = LineStyle.Continuous
borderStyle.Weight = 1.0R
borders.Add(borderStyle)
Next
For Each border As BorderStyles In borders
cstyle.Borders.Add(border)
Next
e.Styles.Add(cstyle)
2. How can I insert a row at the beginning of the output. I have seen many examples on how to do this when using the HTML format but there are no examples when using the ExportML format. The following can be used for the HTML format but there is no <body> tag in when you use the ExportML
Protected Sub rgSummaryReport_GridExporting(source As Object, e As Telerik.Web.UI.GridExportingArgs)
Dim title As String = If(_reportCriteria.AppIsFinalSubmitted, " Final-Submission Report", "Pre-Submission Report")
Dim strHeader As New StringBuilder("<h3><center>" + title + "</center></h3><br>")
strHeader.Append("<h5><b>Contract ID: " + Session("contract_id") + "<br>")
strHeader.Append("Contract Name: " + Session("contract_name") + "<br><br>")
strHeader.Append("Report data is valid as of " + lblReportTimestamp.Text + "</b></h5>")
e.ExportOutput = e.ExportOutput.Replace("<head>", "<head><style type=""text/css"">td {border: 0.1pt solid #000000;}</style>")
e.ExportOutput = e.ExportOutput.Replace("<body>", "<body>" + strHeader.ToString())
e.ExportOutput = e.ExportOutput.Replace("</body>", "Report Downloaded: " + DateTime.Now.ToString() + "</body>")
End Sub
Thank you for your help.
Tracy