将标题行添加到RadGrid导出的Excel工作表

时间:2010-08-18 14:18:12

标签: .net asp.net visual-studio-2010 export-to-excel radgrid

我想从Rad Grid向导出的文件添加Title行。我怎么能这样做?

 <telerik:RadGrid ID="RadGridHist" runat="server" DataSourceID="SqlDataSourceHist" Visible="false"
             AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" OnPageIndexChanged="RadGridHist_PageIndexChanged" 
             OnPageSizeChanged="RadGridHist_PageSizeChanged" OnItemCommand="RadGridHist_ItemCommand" OnSortCommand="RadGridHist_SortCommand" 
             OnGridExporting="RadGridHist_GridExporting" OnExcelMLExportStylesCreated="RadGridHist_ExcelMLExportStylesCreated" AllowFilteringByColumn="true" OnInit="RadGridHist_Init"
             Skin="Windows7">
             <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="true" >
                <Excel Format="Html" />
            </ExportSettings>
                <MasterTableView CommandItemDisplay="Top" >
                <Columns>
                   //stuff
                </Columns>
                    <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false"
                      ExportToExcelText="Export To Excel Spreadsheet"  />
                </MasterTableView>
            </telerik:RadGrid>

1 个答案:

答案 0 :(得分:2)

只需在Item命令上添加一个标题到RadGrid即可。感谢所有精彩的答案!哈哈。

RadGridHist.MasterTableView.Caption = "Title";