OK this is a long one to explain. I have a grid that I have a custom column template that has 2 dates under one heading, but each date has to be sortable. So I followed the demo found here: http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx
That part works. The problem comes when I need to export to Excel. I am trying to export on the server side like this:
It exports fine, but when I try to open it I get an error that says "unknown" check some temporary file at C:\Documents and Settings\username\Local Settings\Temporary Internet Files\Content.MSO\SomeRandomNamedErrorFile.txt
I checked the randomly named error file and it says:
and that's it.
It took me forever to figure out that it was the buttons that let me sort the custom column that were causing the error in the first place. So I tried a couple things and finally got it to export to excel by exporting it like this:
for some reason it didn't like exporting the buttons using ExcelML as the format. I have no problem with exporting it as HTML, but now
the problem is that the exported excel file has the headers of the custom column backwards.
For example,
The grid has:
Period
Start Date - End Date
The excel file has:
row1 : Period
row2 : -
row3: End Date Start Date
(obviously I added the rows as reference to which excel row they show up in)
If it helps I have the column set up like this in the aspx file:
So if anyone has any idea of how to fix this I would appreciate any help you could provide.
Thanks,
Dustin
That part works. The problem comes when I need to export to Excel. I am trying to export on the server side like this:
protected
void
btnXLS_Click(
object
sender, EventArgs e)
{
rgvNextActionDue.ExportSettings.FileName =
"NextActionDue"
;
rgvNextActionDue.ExportSettings.OpenInNewWindow =
true
;
rgvNextActionDue.ExportSettings.ExportOnlyData =
true
;
rgvNextActionDue.ExportSettings.IgnorePaging =
true
;
rgvNextActionDue.ExportSettings.Excel.FileExtension =
"xls"
;
rgvNextActionDue.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
rgvNextActionDue.MasterTableView.ExportToExcel();
}
It exports fine, but when I try to open it I get an error that says "unknown" check some temporary file at C:\Documents and Settings\username\Local Settings\Temporary Internet Files\Content.MSO\SomeRandomNamedErrorFile.txt
I checked the randomly named error file and it says:
It took me forever to figure out that it was the buttons that let me sort the custom column that were causing the error in the first place. So I tried a couple things and finally got it to export to excel by exporting it like this:
protected
void
btnXLS_Click(
object
sender, EventArgs e)
{
rgvNextActionDue.ExportSettings.FileName =
"NextActionDue"
;
rgvNextActionDue.ExportSettings.OpenInNewWindow =
true
;
rgvNextActionDue.ExportSettings.ExportOnlyData =
true
;
rgvNextActionDue.ExportSettings.IgnorePaging =
true
;
rgvNextActionDue.ExportSettings.Excel.FileExtension =
"xls"
;
rgvNextActionDue.ExportSettings.Excel.Format = GridExcelExportFormat.Html;
rgvNextActionDue.MasterTableView.ExportToExcel();
}
the problem is that the exported excel file has the headers of the custom column backwards.
For example,
The grid has:
Period
Start Date - End Date
The excel file has:
row1 : Period
row2 : -
row3: End Date Start Date
(obviously I added the rows as reference to which excel row they show up in)
If it helps I have the column set up like this in the aspx file:
<
tlk:GridTemplateColumn
UniqueName
=
"PeriodTemplate"
Groupable
=
"false"
>
<
HeaderTemplate
>
<
table
id
=
"tblPeriod"
cellspacing
=
"0"
width
=
"100%"
>
<
tr
>
<
td
colspan
=
"3"
align
=
"center"
>
<
b
>Period</
b
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:49%"
align
=
"center"
>
<
asp:LinkButton
CssClass
=
"Button"
ID
=
"btnPStart"
Text
=
"Start"
ToolTip
=
"Sort by Period Start"
CommandName
=
"Sort"
CommandArgument
=
"EvFYStart"
runat
=
"server"
/>
</
td
>
<
td
align
=
"center"
style
=
"width:1%"
>-</
td
>
<
td
style
=
"width:50%"
align
=
"center"
>
<
asp:LinkButton
CssClass
=
"Button"
ID
=
"btnPEnd"
Text
=
"End"
ToolTip
=
"Sort by Period End"
CommandName
=
"Sort"
CommandArgument
=
"EvFYEnd"
runat
=
"server"
/>
</
td
>
</
tr
>
</
table
>
</
HeaderTemplate
>
<
HeaderStyle
Width
=
"120px"
/>
<
ItemTemplate
>
<
table
cellspacing
=
"0"
width
=
"100%"
border
=
"0"
>
<
tr
>
<
td
style
=
"width:49%; border:0;"
align
=
"center"
>
<%# Eval("EvFYStart") %>
</
td
>
<
td
align
=
"center"
style
=
"width:1%; border:0;"
>-</
td
>
<
td
style
=
"width:50%; border:0;"
align
=
"center"
>
<%# Eval("EvFYEnd") %>
</
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
tlk:GridTemplateColumn
>
So if anyone has any idea of how to fix this I would appreciate any help you could provide.
Thanks,
Dustin