如何将FastReportOnlineDesign 灵活的应用到C/S B/S 程序当中?
一.好久没有写博客了,主要是停在这里太久了,有些事情让自己尽量不在去想,忘记不了一段难以忘怀的记忆,就让这一段美好的记忆沉没在无锡的太湖中吧!不在去想了。难以忘怀。。。。。
二.废话不多说了,不如正题,最近在一直忙于AVS 系统的开发基于C/S的。后期的客户主要想做B/S 的。需要在原来的基础上进行一键式安装部署网站到IIS上。 以及将FastReportOnlineDesign 中的报表的功能嵌入到其中的B/S 的应用程序里面。
三.首先你需要进行建立一个B/S 方面的应用的程序。目前我就按照自己的创建的项目进行展示。
1.首先你需要进行下载和按照一个FastReportOnlineDesign 安装包就可以了,然后将其中的程序集部分进行替换掉就可以使用了。
2..创建一个ASP.NET MVC 5.0 方面的应用的程序。下面是创建的应用程序的核心的关于调用FastReportOnlineDesign 里面的方法就可以了。
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using FastReport; using FastReport.Barcode; using FastReport.Editor; using System.Data; using System.Threading; using System.IO; using static System.Net.Mime.MediaTypeNames; using FastReport.Export.Pdf; using System.Diagnostics; namespace FastReportOnlineDesign.Controllers { public class HomeController : Controller { [STAThreadAttribute] public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(string Parameter) { Thread t = new Thread(new ThreadStart(DealReport));//你需要首先创建一个线程 在B/S 应用程序里面必须要这么做否则会报错。 t.ApartmentState = ApartmentState.STA; t.Start(); return View(); } public ActionResult About() { ViewBag.Message = "Your application description page."; return View(); } //对于报表的操作 private void DealReport() { #region 进行汉化处理 string BaseDir = Path.Combine(Application.StartupPath, "File/FastReport"); FastReport.Utils.Res.LocaleFolder = Path.Combine(baseDir, "L18N"); var File = FastReport.Utils.Res.LocaleFolder + @"Chinese (Simplified).frl"; FastReport.Utils.Res.LoadLocale(File); #endregion #region 进行预览FastReport 以及设计FastReport模板 DataSet FDataSet = new DataSet(); DataTable table = new DataTable(); table.TableName = "Admin"; table.Columns.Add("AId", typeof(string)); table.Columns.Add("Akey", typeof(string)); table.Rows.Add(0, "ab"); table.Rows.Add(1, "abc"); table.Rows.Add(2, "ab"); table.Rows.Add(3, "abc"); FDataSet.Tables.Add(table); FastReport.Report report = new FastReport.Report(); try { //report.Load(@"C:\Users\Desktop\FastReportOnlineDesign\FastReportOnlineDesign\FastLayOut\Simple List.frx"); report.RegisterData(FDataSet); report.Design(); report.GetDataSource("Admin").Enabled = true; report.Show(); } catch (Exception ex) { Response.Write(ex.Message); } finally { report.Dispose(); } #endregion } } }
3.直接在前端页面进行应用Ajax 进行使用调用就可以了。
4.如果在C/S 应用程序当中直接使用DealReport() 方法就可以了。
2017/11/15 1:00 :00