Hi.
I have stumbled over a bug (Atleast i think its one).
I want to expert my nested table view into excel. (excel-format: ExcelML)
Word, CSV and Excel with format Html works fine.
But ExcelML crashes with a null exception.
ASPX.Page:
ASPX.CS Code Page:
I have stumbled over a bug (Atleast i think its one).
I want to expert my nested table view into excel. (excel-format: ExcelML)
Word, CSV and Excel with format Html works fine.
But ExcelML crashes with a null exception.
ASPX.Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestGrid.aspx.cs" Inherits="TestGrid" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"ScriptManager"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGrid1"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
EnableLinqExpressions
=
"false"
>
<
ExportSettings
HideStructureColumns
=
"true"
ExportOnlyData
=
"true"
IgnorePaging
=
"true"
Excel-Format
=
"ExcelML"
/>
<
PagerStyle
Mode
=
"NumericPages"
AlwaysVisible
=
"true"
/>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
ShowHeader
=
"true"
AutoGenerateColumns
=
"False"
AllowPaging
=
"true"
DataKeyNames
=
"ID, PARENT_ID"
CommandItemDisplay
=
"Top"
AllowMultiColumnSorting
=
"True"
EditMode
=
"InPlace"
HierarchyLoadMode
=
"Client"
FilterExpression
=
"PARENT_ID = 0 or PARENT_ID IS NULL"
>
<
CommandItemTemplate
>
<
asp:Button
ID
=
"ExportToExcelButton"
runat
=
"server"
CommandName
=
"ExportToExcel"
Text
=
"Export to Excel"
/>
<
asp:Button
ID
=
"ExportToWordButton"
runat
=
"server"
CommandName
=
"ExportToWord"
Text
=
"Export to Word"
/>
<
asp:Button
ID
=
"ExportToCsvButton"
runat
=
"server"
CommandName
=
"ExportToCsv"
Text
=
"Export to Csv"
/>
</
CommandItemTemplate
>
<
SelfHierarchySettings
ParentKeyName
=
"PARENT_ID"
KeyName
=
"ID"
MaximumDepth
=
"0"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
/>
<
telerik:GridBoundColumn
DataField
=
"PARENT_ID"
/>
<
telerik:GridBoundColumn
DataField
=
"NAME"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
form
>
</
body
>
</
html
>
ASPX.CS Code Page:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
Telerik.Web.UI;
public
partial
class
TestGrid : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
private
DataTable GetDataTable()
{
DataTable returnValue =
new
DataTable();
returnValue.Columns.Add(
"ID"
);
returnValue.Columns.Add(
"PARENT_ID"
);
returnValue.Columns.Add(
"NAME"
);
DataRow row = returnValue.NewRow();
row[
"ID"
] = 1;
row[
"PARENT_ID"
] = 0;
row[
"NAME"
] =
"Parent A"
;
returnValue.Rows.Add(row);
row = returnValue.NewRow();
row[
"ID"
] = 2;
row[
"PARENT_ID"
] = 1;
row[
"NAME"
] =
"Child A"
;
returnValue.Rows.Add(row);
row = returnValue.NewRow();
row[
"ID"
] = 3;
row[
"PARENT_ID"
] = 1;
row[
"NAME"
] =
"Child B"
;
returnValue.Rows.Add(row);
row = returnValue.NewRow();
row[
"ID"
] = 4;
row[
"PARENT_ID"
] = 1;
row[
"NAME"
] =
"Child C"
;
returnValue.Rows.Add(row);
row = returnValue.NewRow();
row[
"ID"
] = 5;
row[
"PARENT_ID"
] = 0;
row[
"NAME"
] =
"Parent B"
;
returnValue.Rows.Add(row);
return
returnValue;
}
protected
void
RadGrid1_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable();
}
}