本文介绍了Radgrid导出到excel不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我将radgrid数据导出到excel,但是我的代码不能正常工作,我有什么问题请不要帮助我。

.aspx page代码

< Rad:RadGrid ID =GvPVoltrunat =serverAutoGenerateColumns =FalseGridLines =Both

OnItemCommand =GvPVolt_ItemCommand önPageIndexChanged=GvPVolt_PageIndexChangedOnPreRender =GvPVolt_PreRenderAllowSorting =trueAllowPaging =truePageSize =10

GroupingEnabled =trueSkin =OutlookShowGroupPanel =true> ;

< pagerstyle mode =NextPrevAndNumeric>

< mastertableview commanditemdisplay =Topenablenorecordstemplate =true>

<列> < rad:gridboundcolumn datafield =Siteidheaderstyle-font-bold =trueheadertext =Siteidxmlns:rad =#unknown>

HeaderStyle-Horizo​​ntalAlign =CenterItemStyle -Horizo​​ntalAlign =Center/>

< rad:gridboundcolumn datafield =Rxdateheaderstyle-font-bold =trueheadertext =Date& Time>

HeaderStyle-Horizo​​ntalAlign =LeftItemStyle-Horizo​​ntalAlign =Right/>

< rad:gridboundcolumn datafield =RphaseCurrentheaderstyle-font-bold =trueheadertext = R相电流>

HeaderStyle-Horizo​​ntalAlign =LeftItemStyle-Horizo​​ntalAlign =Left/>

< rad:gridboundcolumn headerstyle-horizo​​ntalalign = leftheaderstyle-font-bold =true>

ItemStyle-Horizo​​ntalAlign =LeftDataField =YphaseCurrent HeaderText =Y相电流/>

< rad:gridboundcolumn headerstyle-horizo​​ntalalign =左headerstyle-font-bold =true>

ItemStyle-Horizo​​ntalAlign =RightDataField =BphaseCurrentHeaderText =B相电流/>

< commanditemsettings showexporttoexcelbutton =trueshowrefreshbutton =trueshowaddnewrecordbutton =false>



< exportsettings hidestructurecolumns = trueexcel-format =Html>

< clientsettings allowcolumnsreorder =trueallowdragtogroup =truereordercolumnsonclient =true>

ColumnsReorderMethod =重新排序>

< resizing allowrowresize =falseenablerealtimeresize =Trueresizegridoncolumnresize =True>

AllowColumnResize =True>







公共部分class Reports_FaultCurrentReport:System.Web.UI.Page

{

protected void Page_Load(object sender,EventArgs e)

{

if(!IsPostBack)

{

BindGraph();



}

}

protected void BindGraph()

{

ds = DataAccessLayer.BindDataQuery(select Siteid,Rxdate,来自tblsitedata1的RphaseCurrent,其中Siteid ='+ Session [Transformer]。ToString()+'和RphaseCurrent< '+ ViewState [CurrentL] +'和RxDate介于'+ frmTime +'和dateadd(second,-1,'+ tTime +'));

GvPVolt .DataSource = ds;

GvPVolt.DataBind();

}

protected void GvPVolt_PreRender(object sender,EventArgs e)

{

BindGraph();

}

protected void GvPVolt_ItemCommand(object sender,GridCommandEventArgs e)

{

if(e.CommandName == RadGrid.ExportToExcelCommandName)

ConfigureExport();

}

public void ConfigureExport()

{

GvPVolt.ExportSettings.ExportOnlyData = false;

GvPVolt.ExportSettings.IgnorePaging = true;

GvPVolt.ExportSettings.OpenInNewWindow = true;

GvPVolt.MasterTableView.ExportToExcel();

}

}

While i am exporting the radgrid data to the excel it is not working below is my code,what is the problem i am not getting please help me from this.
.aspx page code
<Rad:RadGrid ID="GvPVolt" runat="server" AutoGenerateColumns="False" GridLines="Both"
OnItemCommand="GvPVolt_ItemCommand" önPageIndexChanged="GvPVolt_PageIndexChanged" OnPreRender="GvPVolt_PreRender" AllowSorting="true" AllowPaging="true" PageSize="10"
GroupingEnabled="true" Skin="Outlook" ShowGroupPanel="true" >
<pagerstyle mode="NextPrevAndNumeric">
<mastertableview commanditemdisplay="Top" enablenorecordstemplate="true">
<columns> <rad:gridboundcolumn datafield="Siteid" headerstyle-font-bold="true" headertext="Siteid" xmlns:rad="#unknown">
HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
<rad:gridboundcolumn datafield="Rxdate" headerstyle-font-bold="true" headertext="Date & Time">
HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Right" />
<rad:gridboundcolumn datafield="RphaseCurrent" headerstyle-font-bold="true" headertext="R-phase Current">
HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
<rad:gridboundcolumn headerstyle-horizontalalign="Left" headerstyle-font-bold="true">
ItemStyle-HorizontalAlign="Left" DataField="YphaseCurrent" HeaderText="Y-phase Current" />
<rad:gridboundcolumn headerstyle-horizontalalign="Left" headerstyle-font-bold="true">
ItemStyle-HorizontalAlign="Right" DataField="BphaseCurrent" HeaderText="B-phase Current" />
<commanditemsettings showexporttoexcelbutton="true" showrefreshbutton="true" showaddnewrecordbutton="false">

<exportsettings hidestructurecolumns="true" excel-format="Html">
<clientsettings allowcolumnsreorder="true" allowdragtogroup="true" reordercolumnsonclient="true">
ColumnsReorderMethod="Reorder">
<resizing allowrowresize="false" enablerealtimeresize="True" resizegridoncolumnresize="True">
AllowColumnResize="True">



public partial class Reports_FaultCurrentReport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGraph();

}
}
protected void BindGraph()
{
ds = DataAccessLayer.BindDataQuery("select Siteid,Rxdate,RphaseCurrent from tblsitedata1 where Siteid='" + Session["Transformer"].ToString() + "' and RphaseCurrent < '" + ViewState["CurrentL"] + "' and RxDate between '" + frmTime + "' and dateadd( second,-1,'" + tTime + "' )");
GvPVolt.DataSource = ds;
GvPVolt.DataBind();
}
protected void GvPVolt_PreRender(object sender, EventArgs e)
{
BindGraph();
}
protected void GvPVolt_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.ExportToExcelCommandName)
ConfigureExport();
}
public void ConfigureExport()
{
GvPVolt.ExportSettings.ExportOnlyData = false;
GvPVolt.ExportSettings.IgnorePaging = true;
GvPVolt.ExportSettings.OpenInNewWindow = true;
GvPVolt.MasterTableView.ExportToExcel();
}
}

推荐答案



这篇关于Radgrid导出到excel不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 00:21