时间:2021-03-02 11:44:33 | 栏目:.NET代码 | 点击:次
1:新建?蟊硭?需的???源DataSet.cs
namespace ********
{
public class DataSet
{
public DataTable CreatDataSet()
{
DataTable dt = new DataTable();
dt.Columns.Add("A");
dt.Columns.Add("B");
dt.Columns.Add("C");
return dt;
}
}
}
2:?O??蟊?

?蟊碓O??@?e就不涉及了
3:把第一步新建的???源加到?蟊硌Y面?定
注意:?@?e需要先引用 Interop.VBA.dll 才可以把新建的CS文件作????源??入

把???源??入后?定即可
4:直接把?蟊?С??PDF,Excel等格式
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
byte[] bytes = viewer.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
//Excel ,PDF ,Word 等格式
// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=1_" + DateTime.Now.ToString("yyyyMMddhhssmm") + "" + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download
5:在?面引用?蟊恚?rpResult??蟊砜丶?)
至此,?蟊淼漠a出和?@示都OK了,如果需要更深入的了解,?查看其它文章