本文介绍了无法找到类型或命名空间XLWorkbook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

亲爱的朋友,



我需要将折叠gridview导出为ex​​cel。我有这个代码中的问题。找不到类型或命名空间XLWorkbook。这里有什么问题。



DataTable dt = new DataTable(GridView_Data);

GridView gvOrders =(GridView)gvCustomers.Rows [1] .FindControl(gvOrders);

foreach(gvCustomers.HeaderRow.Cells中的TableCell单元格)

{

dt.Columns .Add(cell.Text);

}

foreach(gvOrders.HeaderRow.Cells中的TableCell单元格)

{

dt.Columns.Add(cell.Text);

}

dt.Columns.RemoveAt(0);

foreach( gvCustomers.Rows中的GridViewRow行)

{

GridView gvOrderscell =(row.FindControl(gvOrders)as GridView);

for( int j = 0; j< gvOrderscell.Rows.Count; j ++)

{

dt。 Rows.Add(row.Cells [1] .Text,row.Cells [2] .Text,gvOrderscell.Rows [j] .Cells [0] .Text,gvOrderscell.Rows [j] .Cells [1] .Text) ;

}

}

使用(XLWorkbook wb =新XLWorkbook())

{

wb.Worksheets.Add(dt);



Response.Clear();

Response.Buffer = true;

Response.Charset =;

Response.ContentType =application / vnd.openxmlformats-officedocument.spreadsheetml.sheet;

响应。 AddHeader(content-disposition,attachment; filename = GridView.xlsx);

使用(MemoryStream MyMemoryStream = new MemoryStream())

{

wb.SaveAs(MyMemoryStream);

MyMemoryStream.WriteTo(Response.OutputStream) ;

Response.Flush();

Response.End();

}

}

Dear Frnds,

I need to export the collapse gridview to excel. i have the problem in this code. Type or namespace 'XLWorkbook' could not be found. what is the problem here.

DataTable dt = new DataTable("GridView_Data");
GridView gvOrders = (GridView)gvCustomers.Rows[1].FindControl("gvOrders");
foreach (TableCell cell in gvCustomers.HeaderRow.Cells)
{
dt.Columns.Add(cell.Text);
}
foreach (TableCell cell in gvOrders.HeaderRow.Cells)
{
dt.Columns.Add(cell.Text);
}
dt.Columns.RemoveAt(0);
foreach (GridViewRow row in gvCustomers.Rows)
{
GridView gvOrderscell = (row.FindControl("gvOrders") as GridView);
for (int j = 0; j < gvOrderscell.Rows.Count; j++)
{
dt.Rows.Add(row.Cells[1].Text, row.Cells[2].Text, gvOrderscell.Rows[j].Cells[0].Text, gvOrderscell.Rows[j].Cells[1].Text);
}
}
using (XLWorkbook wb = new XLWorkbook())
{
wb.Worksheets.Add(dt);

Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment;filename=GridView.xlsx");
using (MemoryStream MyMemoryStream = new MemoryStream())
{
wb.SaveAs(MyMemoryStream);
MyMemoryStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
}
}

推荐答案


这篇关于无法找到类型或命名空间XLWorkbook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:43