Beispiel #1
0
        private void radButton1_Click(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            //set any deviceInfo settings if necessary
            System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();

            //Print Slip Gaji
            rptBarangKeluarTabel rpt1 = new rptBarangKeluarTabel();

            rpt1.ReportParameters[0].Value = DateTime.Now;
            //gj.ReportParameters["User"].Value = NBConfig.ValidUserName;
            IReportDocument report1 = (IReportDocument)rpt1;

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("XLS", report1, deviceInfo);
            string fileName = "SURATJALAN_" + DateTime.Now.ToString("ddMMMyy") + "." + result.Extension;

            const string path     = @"\\sinarekserver\forms\";
            string       filePath = System.IO.Path.Combine(path, fileName);

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Save Report to a file to a specified location
        /// </summary>
        /// <param name="rptDoc"></param>
        /// <param name="Location"></param>
        internal static void SavedToEXCEL(IReportDocument rptDoc, string Location)
        {
            ReportProcessor      reportProcessor = new ReportProcessor();
            InstanceReportSource reportSource    = new InstanceReportSource();

            reportSource.ReportDocument = rptDoc;
            string    rptName = string.Empty;
            Hashtable htbl    = new Hashtable();

            //set any deviceInfo settings if necessary
            System.Collections.Hashtable deviceInfo             = new System.Collections.Hashtable();
            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("XLS", reportSource, deviceInfo);
            string fileName = result.DocumentName + "." + result.Extension;
            string filePath = System.IO.Path.Combine(Location, fileName);

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }