各位好,向大家请教个问题,是这样的,我在rdlc数据表中绑定了数据库中的数据,我不想让它在页面上显示,而想当我按页面上的一个按钮button1时,自动把该rdlc数据表导出到excel中去,请问该怎么实现呢,请知道的帮忙告诉一声,先在此谢谢大家了。
解决方案 »
- 解决C#连接数据库转义字符问题
- 紧急求助!手机模拟器中实现音频格式由WAV向MP3的转换
- C#如何在txt文本某个数据的后来添加字符呢?
- 急需请高手解决的问题(关于C#调用C++的DLL,参数为指向Struct的指针)
- 请问datetimerpicker控件中的日期能不能设置成不同的背景色,例如把节日设置成绿色,其它的为白色.
- 那些控件容器可以遍历
- 用asp后台语句进行页面的定时跳转
- Repeater 如何实现分页
- winform更新中,如何在文件复制完后,再去修改配置文件的版本号
- 关于在WebApplication项目中使用process的问题
- 关于.NET中MDI子窗体的问题?
- 求助 专家系统
static void Test()
{
LocalReport lr = new LocalReport(); string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>Excel</OutputFormat>" +
"</DeviceInfo>"; lr.ReportPath = @"C:\My Reports\Monthly Sales.rdlc";
lr.DataSources.Add(new ReportDataSource("Sales", GetSalesData())); string mimeType, encoding, extension;
string[] streams;
Warning[] warnings; byte[] bytes = lr.Render(
"Excel",
deviceInfo,
out mimeType,
out encoding,
out extension,
out streams,
out warnings); using (FileStream fs = new FileStream(@"c:\My Reports\Monthly Sales.xls", FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
}
用户代码未处理 Microsoft.Reporting.WebForms.LocalProcessingException
Message="本地报表处理期间出错。"
Source="Microsoft.ReportViewer.WebForms"
StackTrace:
在 Microsoft.Reporting.WebForms.LocalReport.CompileReport()
在 Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
在 Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
在 Microsoft.Reporting.WebForms.LocalReport.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
在 viiPOS.Reports.Rpt_StockSummary.Button1_Click(Object sender, EventArgs e) 位置 C:\Documents and Settings\SH_XuWuKe\My Documents\Visual Studio 2005\Projects\viiPOS 2.6.0\viiPOSManager\Reports\Rpt_StockSummary.aspx.cs:行号 226
在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
提示错误出现在
byte[] bytes = lr.Render(
"Excel",
deviceInfo,
out mimeType,
out encoding,
out extension,
out streams,
out warnings);