private void toolExcel_Click(object sender, EventArgs e) { Microsoft.Reporting.WinForms.Warning[] Warnings; string[] strStreamIds; string strMimeType; string strEncoding; string strFileNameExtension; byte[] bytes = this.rptViewer.LocalReport.Render("Excel", null, out strMimeType, out strEncoding, out strFileNameExtension, out strStreamIds, out Warnings); //string strFilePath = @"D:\" + this.GetTimeStamp() + ".xls";
SaveFileDialog Dialog = new SaveFileDialog(); Dialog.Filter = "*.xls|*.*"; Dialog.ShowDialog();
string strFilePath = Dialog.FileName; using (System.IO.FileStream fs = new FileStream(strFilePath, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); } if (Pub.WinForm.Msg.Question("报表打印: \r\n 成功导出Excel文件!" + strFilePath + "\r\n 要现在打开文件" + strFilePath + "吗?") == DialogResult.Yes) { System.Diagnostics.Process.Start(strFilePath); } }
from http://www.cnblogs.com/waxdoll/archive/2006/03/03/342435.html
转载于:https://www.cnblogs.com/kevenzeng/archive/2012/03/19/2406607.html
相关资源:数据结构—成绩单生成器