内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Asp.net中怎么使用報表-創(chuàng)新互聯(lián)

本篇文章為大家展示了Asp.net中怎么使用報表,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

成都創(chuàng)新互聯(lián)專注于企業(yè)成都全網(wǎng)營銷、網(wǎng)站重做改版、岳陽網(wǎng)站定制設計、自適應品牌網(wǎng)站建設、H5頁面制作商城網(wǎng)站制作、集團公司官網(wǎng)建設、外貿(mào)網(wǎng)站建設、高端網(wǎng)站制作、響應式網(wǎng)頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為岳陽等各大城市提供網(wǎng)站開發(fā)制作服務。

1:新建報表所需的數(shù)據(jù)源DataSet.cs

 代碼如下:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace ********
{
    public class DataSet
    {
        public DataTable CreatDataSet()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("A");
            dt.Columns.Add("B");
            dt.Columns.Add("C");
            return dt;

        }
    }
}


指定所需要綁定的Table的列,返回dataTable 類,CreatDataSet方法名稱隨便起,也可以在一個類裏面定義多個方法(不同數(shù)據(jù)源)

2:設計報表

Asp.net中怎么使用報表

報表設計這裡就不涉及了

3:把第一步新建的數(shù)據(jù)源加到報表裏面綁定

 注意:這裡需要先引用 Interop.VBA.dll 才可以把新建的CS文件作為數(shù)據(jù)源導入

Asp.net中怎么使用報表

把數(shù)據(jù)源導入后綁定即可

4:直接把報表導出為PDF,Excel等格式

復制代碼 代碼如下:


ReportViewer viewer = new ReportViewer();
            viewer.ProcessingMode = ProcessingMode.Local;
            viewer.LocalReport.ReportEmbeddedResource = "***.Page.Report.Report1.rdlc";
            ReportDataSource rds_1 = new ReportDataSource("DataSet1", dtReport);//DataSet1為報表裏面的數(shù)據(jù)源名稱
            viewer.LocalReport.DataSources.Add(rds_1);

            ReportParameter rp1 = new ReportParameter("參數(shù)1","參數(shù)1的值" );//給參數(shù)賦值
            ReportParameter rp2 = new ReportParameter("參數(shù)2","參數(shù)2的值" );
            viewer.LocalReport.SetParameters(new ReportParameter[] {rp1, rp2 });

            Warning[] warnings;
            string[] streamIds;
            string mimeType = string.Empty;
            string encoding = string.Empty;
            string extension = string.Empty;

            byte[] bytes = viewer.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            //Excel ,PDF ,Word 等格式
            // Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", "attachment; filename=1_" + DateTime.Now.ToString("yyyyMMddhhssmm") + "" + "." + extension);
            Response.BinaryWrite(bytes); // create the file
            Response.Flush(); // send it to the client to download


5:在頁面引用報表(rpResult為報表控件)

復制代碼 代碼如下:


DataTable dt = new DataTable();//自己拼出數(shù)據(jù)源就可以
                ReportDataSource repDataSource = new ReportDataSource("DataSet1", dt);

                //*設置報表參數(shù),并顯示
                this.rpResut.LocalReport.ReportEmbeddedResource = "***.Page.Report.Report1.rdlc"";
                this.rpResut.LocalReport.DataSources.Clear();
                this.rpResut.LocalReport.DataSources.Add(repDataSource);
                 ReportParameter rp1 = new ReportParameter("參數(shù)1","參數(shù)1的值" );//給參數(shù)賦值
                  ReportParameter rp2 = new ReportParameter("參數(shù)2","參數(shù)2的值" );

                this.rpResut.LocalReport.SetParameters(new ReportParameter[] {rp1, rp2 });
                this.rpResut.DataBind();
                this.rpResut.LocalReport.Refresh();


上述內(nèi)容就是Asp.net中怎么使用報表,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁題目:Asp.net中怎么使用報表-創(chuàng)新互聯(lián)
當前路徑:http://www.rwnh.cn/article36/doshpg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、ChatGPT、品牌網(wǎng)站設計、動態(tài)網(wǎng)站網(wǎng)站策劃、自適應網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化
呼图壁县| 若尔盖县| 新民市| 柳江县| 庐江县| 都昌县| 怀宁县| 克山县| 玉门市| 观塘区| 汉沽区| 曲麻莱县| 确山县| 泰兴市| 江门市| 扎赉特旗| 招远市| 碌曲县| 浑源县| 金堂县| 三穗县| 凌海市| 防城港市| 平阴县| 手游| 绵竹市| 高雄县| 鄱阳县| 邵东县| 阜平县| 都江堰市| 永顺县| 班戈县| 祁阳县| 汉中市| 广西| 城步| 辽源市| 靖安县| 常熟市| 营山县|