コード例 #1
0
        public static void SaveToExcel(Page page, ReportViewer rptViewer, string fileName)
        {
            ExcelDeviceInfo deviceInfo = new ExcelDeviceInfo();

            SaveToExcel(page, rptViewer, fileName, deviceInfo);
        }
コード例 #2
0
        public static void SaveToExcel(Page page, ReportViewer rptViewer, string fileName, ExcelDeviceInfo deviceInfo)
        {
            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    extension;

            byte[] bytes = rptViewer.LocalReport.Render(
                deviceInfo.OutputFormat, deviceInfo.ToString(),
                out mimeType, out encoding,
                out extension, out streamids, out warnings);


            string savePath = fileName;

            using (FileStream stream = new FileStream(savePath, FileMode.Create))
            {
                stream.Write(bytes, 0, bytes.Length);
            }
        }
コード例 #3
0
        public static void ExportToExcel(Page page, ReportViewer rptViewer, string fileName, ExcelDeviceInfo deviceInfo)
        {
            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    extension;

            byte[] bytes = rptViewer.LocalReport.Render(
                deviceInfo.OutputFormat, deviceInfo.ToString(),
                out mimeType, out encoding,
                out extension, out streamids, out warnings);

            FileInfo fInfo = new FileInfo(Path.GetTempFileName());

            FileStream fs = new FileStream(fInfo.FullName, FileMode.Create);

            fs.Write(bytes, 0, bytes.Length);
            fs.Close();

            FileHelper.DownloadFile(page, fInfo.DirectoryName, fInfo.Name, fileName);
        }