lzsh0622来接分,感谢帮忙!!!

解决方案 »

  1.   

    为了避嫌,贴上代码 重写ReportExport,导出EXCELpublic void ReportExport(object sender, ReportExportEventArgs e)
            {
                string fileName = "c:\\output.xls";
                SaveFileDialog fd = new SaveFileDialog();
                fd.DefaultExt = ".XLS";           // 扩展名
                fd.FileName = fileName;   // 默认值
                if (fd.ShowDialog() == DialogResult.Cancel) return;            fileName = fd.FileName;
                if (File.Exists(fileName))
                {
                    FileInfo fi = new FileInfo(fd.FileNames[0]);
                    if (fi.IsReadOnly)
                    {
                        MessageBox.Show(fd.FileName + "文件只读"); return;
                    }
                }            Warning[] warnings;
                string[] streamids;
                string mimeType;
                string encoding;
                string extension;            byte[] bytes = (sender as ReportViewer).LocalReport.Render("Excel", null, out mimeType, out encoding, out extension,out streamids, out warnings);
                FileStream fs = new FileStream(fileName, FileMode.Create);
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();            MessageBox.Show( "成功导出:"+fileName);
            }