将数据从网格导出到excel文件时出现问题,获取复选框coulmn并将所有drop dropdownlist值导入excel [英] Problem in exporting data to an excel file from a grid getting checkbox coulmn and all drop dropdownlist values into excel

查看:112
本文介绍了将数据从网格导出到excel文件时出现问题,获取复选框coulmn并将所有drop dropdownlist值导入excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格中的3个下拉列表和标题中的复选框字段,并且在每个rec的开头,我必须将网格记录导出到excel文件,同时将数据从网格导出到excel文件我看到excel单击时文件单元格也显示所有下拉列表值。我只想导出下拉列表的选定值,并希望省略第一个复选框列。如何做到可以任何人帮助

我的代码如下

--------------------- ----------------



Response.ClearContent();

Response.AppendHeader( content-disposition,attachment; filename = Studs.xls);

Response.ContentType =application / excel;



StringWriter stringwriter = new StringWriter();

HtmlTextWriter htmlTextwriter = new HtmlTextWriter(stringwriter);



gridRecs.HeaderRow.Style.Add( background-color,#FFFFFF);



foreach(GridRecs.HeaderRow.Cells中的TableCell tablecell)

{

tablecell.Style [background-color] =#507CD1;

}



foreach(GridViewRow) gridRecs.Rows中的gridViewRow)

{

gridViewRow.BackColor = System.Drawing.Color.White;

foreach(Tabl gridViewRow.Cells中的eCell gridViewRowTablecell)

{

gridViewRowTablecell.Style [background-color] =#D1DDF1;

} < br $>
}



gridRecs.RenderControl(htmlTextwriter);

Response.Write(stringwriter.ToString());

Response.End();

Hi i have 3 dropdownlists in a grid and a checkbox field in header and at beginning of each rec, i have to export the grid records to an excel file , while exporting data from a grid to excel file i see that the excel file cell when clicked is showing all dropdownlist values also. I just want to export the selected values of the dropdown and want to omit the first check box column . How to do it can any one help
My code is as below
-------------------------------------

Response.ClearContent();
Response.AppendHeader("content-disposition", "attachment; filename=Studs.xls");
Response.ContentType = "application/excel";

StringWriter stringwriter = new StringWriter();
HtmlTextWriter htmlTextwriter = new HtmlTextWriter(stringwriter);

gridRecs.HeaderRow.Style.Add("background-color", "#FFFFFF");

foreach (TableCell tablecell in gridRecs.HeaderRow.Cells)
{
tablecell.Style["background-color"] = "#507CD1";
}

foreach (GridViewRow gridViewRow in gridRecs.Rows)
{
gridViewRow.BackColor = System.Drawing.Color.White;
foreach (TableCell gridViewRowTablecell in gridViewRow.Cells)
{
gridViewRowTablecell.Style["background-color"] = "#D1DDF1";
}
}

gridRecs.RenderControl(htmlTextwriter);
Response.Write(stringwriter.ToString());
Response.End();

推荐答案

这篇关于将数据从网格导出到excel文件时出现问题,获取复选框coulmn并将所有drop dropdownlist值导入excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆