如何將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  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM