如何將FastReportOnlineDesign 靈活的應用到C/S B/S 程序當中?

一.很久沒有寫博客了,主要是停在這裏過久了,有些事情讓本身儘可能不在去想,忘記不了一段難以忘懷的記憶,就讓這一段美好的記憶沉沒在無錫的太湖中吧!不在去想了。難以忘懷。。。。。前端

二.廢話很少說了,不如正題,最近在一直忙於AVS 系統的開發基於C/S的。後期的客戶主要想作B/S 的。須要在原來的基礎上進行一鍵式安裝部署網站到IIS上。 以及將FastReportOnlineDesign 中的報表的功能嵌入到其中的B/S 的應用程序裏面。app

三.首先你須要進行創建一個B/S 方面的應用的程序。目前我就按照本身的建立的項目進行展現。網站

1.首先你須要進行下載和按照一個FastReportOnlineDesign 安裝包就能夠了,而後將其中的程序集部分進行替換掉就能夠使用了。spa

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() 方法就能夠了。 code

                                                                                                                                              2017/11/15  1:00 :00  blog

相關文章
相關標籤/搜索