作者:cfncjl_130 | 来源:互联网 | 2023-05-19 06:21
Exportingfromc#.netIamgettingaproblemIhaveaformthatwhenIexporttoexcelasaresulti
Exporting from c#.net I am getting a problem I have a form that when I export to excel as a result in excel Any ideas why is this happening I am including the ASP code below.
从c#.net导出我遇到问题我有一个表单,当我导出excel导致excel任何想法为什么会发生这种情况我包括下面的ASP代码。
<%@ Page Language="C#" MasterPageFile="~/masterpages/Admin.master" AutoEventWireup="true" CodeFile="members-search-adv.aspx.cs" Inherits="masteradmin_members_search_adv" Title="LISA - Life Insurance Settlement" %>
<%@ Register TagPrefix="UC" TagName="Paging" Src="~/controls/Paging.ascx" %>
Go to Quick Search
Contact Database - Advanced Search
OpenSearch: |
* *Search By Company Name, First Name, Last Name, Tags, Comments |
Industry Segment: |
|
Member Type: |
|
Member Rep only: |
|
Board Only: |
|
|
|
|
<%--split the table here--%>
Suspended Only: |
|
Active Only: |
|
Allow Other Members To See My Info Only: |
|
State: |
|
By Special Level: |
|
Sort by: |
Company
First Name
Last Name
Membership Type
Industry Segment
|
|
|
Export To Excel
* Click on the column to SORT |
Company |
First Name |
Last Name |
Email |
|
|
|
|
<%--
--%>
Sorry but this is a better explanation of the issue Exporting from c#.net I am getting a problem I have a form that when I export to excel I ge the following
I have data in the datagrid but not in excel I am just getting
对不起,但这是一个更好的解释问题从c#.net导出我遇到问题我有一个表单,当我导出到Excel时我ge以下
And this is the function that I am using
这是我正在使用的功能
void ExportToExcel3()
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.COntentType= "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView2.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
I am populating the datagrid prior to the export. This is the line of code. It's funny I create a new webform just with this section of code and the export worked. Do you think there's a problem with the datarepeater that I have in the page that is causing the conflict.
我在导出之前填充数据网格。这是代码行。有趣的是,我只使用这部分代码创建了一个新的webform,并且导出工作正常。您是否认为我在页面中导致冲突的datarepeater存在问题。
MemberList list = MemberDB.GetMembers(sql, m_page, m_RecordPerPage, out count, _state);
this.GridView2.DataSource = list;
this.GridView2.DataBind();
2 个解决方案