当前位置: 首页>>代码示例>>C#>>正文


C# ReportDocument.ExportToStream方法代码示例

本文整理汇总了C#中CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream方法的典型用法代码示例。如果您正苦于以下问题:C# ReportDocument.ExportToStream方法的具体用法?C# ReportDocument.ExportToStream怎么用?C# ReportDocument.ExportToStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CrystalDecisions.CrystalReports.Engine.ReportDocument的用法示例。


在下文中一共展示了ReportDocument.ExportToStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowReportD


//.........这里部分代码省略.........
            drA[3] = Convert.ToDecimal(dt.Rows[i][3].ToString());
            drA[4] = Convert.ToDecimal(dt.Rows[i][4].ToString());
            drA[5] = Convert.ToDecimal(dt.Rows[i][5].ToString());
            drA[6] = Convert.ToDecimal(dt.Rows[i][6].ToString());
            drA[7] = Convert.ToDecimal(dt.Rows[i][7].ToString());
            for (int j = 0; j < iMaxTarget; j++)
            {
                drA[8 + j] = Convert.ToDecimal(dt.Rows[i][8 + j].ToString());
            }

            for (int k = 0; k < iMaxSubsidy; k++)
            {
                drA[8 + iMaxTarget + k] = Convert.ToDecimal(dt.Rows[i][18 + k].ToString());
            }
            drA[8 + iMaxTarget + iMaxSubsidy] = Convert.ToDecimal(dt.Rows[i][28].ToString());

            for (int l = 29; l < 29 + iMaxTarget; l++)
            {
                if (dt.Rows[i][l].ToString() != "")
                    drA[l] = arrField[l - 29] + ":" + dt.Rows[i][l].ToString();
                else
                    drA[l] = dt.Rows[i][l].ToString();
            }
            dtR.Rows.Add(drA);
        }


        report.SetDataSource(dtR);
        //this.CryView.ReportSource = null;
        //ParameterFields par1 = new ParameterFields();
        //AddParameter("par_Program_ID", "VAM134R", par1);
        if (this.rdoType4.Checked)
            report.SetParameterValue("par_Program_ID", "VAM134R");
        else
            report.SetParameterValue("par_Program_ID", "VAM135R");
        //ParameterFields par2 = new ParameterFields();
        //AddParameter("par_LoginUser", Session["UID"].ToString() + Login_Name, par2);
        report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);

        report.SetParameterValue("par_YEAR_MONTH", this.SLP_YearMonth1.Text.Trim());
        //ParameterFields par4 = new ParameterFields();
        if (this.rdoPrint1.Checked)
            //AddParameter("par_TYPE", "全部", par4);
            report.SetParameterValue("par_TYPE", "全部");
        else
            //AddParameter("par_TYPE", "分頁", par4);
            report.SetParameterValue("par_TYPE", "分頁");



        //this.CryView.ParameterFieldInfo.Add(par1[0]);
        //this.CryView.ParameterFieldInfo.Add(par2[0]);
        //this.CryView.ParameterFieldInfo.Add(par3[0]);
        //this.CryView.ParameterFieldInfo.Add(par4[0]);
        for (int j = 0; j < iMaxTarget; j++)
        {
            //ParameterFields pars = new ParameterFields();
            //AddParameter("par_Field" + Convert.ToString(9 + j), arrField[j], pars);
            //this.CryView.ParameterFieldInfo.Add(pars[0]);
            report.SetParameterValue("par_Field" + Convert.ToString(9 + j), arrField[j]);
        }

        for (int j = 0; j < iMaxSubsidy; j++)
        {
            //ParameterFields pars = new ParameterFields();
            //AddParameter("par_Field" + Convert.ToString(9 + iMaxTarget + j), arrField1[j], pars);
            //this.CryView.ParameterFieldInfo.Add(pars[0]);
            report.SetParameterValue("par_Field" + Convert.ToString(9 + iMaxTarget + j), arrField1[j]);
        }

        //ParameterFields par5 = new ParameterFields();
        //AddParameter("par_Field" + Convert.ToString(9 + iMaxTarget + iMaxSubsidy), "未稅金額", par5);
        //this.CryView.ParameterFieldInfo.Add(par5[0]);
        report.SetParameterValue("par_Field" + Convert.ToString(9 + iMaxTarget + iMaxSubsidy), "未稅金額");

        for (int j = 0; j < 20 - (iMaxTarget + iMaxSubsidy); j++)
        {
            //ParameterFields pars = new ParameterFields();
            //AddParameter("par_Field" + Convert.ToString(10 + iMaxTarget + iMaxSubsidy + j), "", pars);
            //this.CryView.ParameterFieldInfo.Add(pars[0]);
            report.SetParameterValue("par_Field" + Convert.ToString(10 + iMaxTarget + iMaxSubsidy + j), "");
        }

        //this.CryView.ReportSource = report;
        //檔案匯出
        System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytesPDF = new byte[streamPDF.Length];
        streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
        streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("停止往來及合約追溯彙總表.PDF", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/pdf";
        Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
        Response.Flush();
        Response.Close();
        report.Close();
        #endregion
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:VAM131.aspx.cs

示例2: LoadCrystalReport

    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":
                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();

                break;
            case "PDF":
                //string s_par_Program_ID = this.PageCode;
                string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();
                string s_par_Program_ID = "MKT11";
                string s_par_LoginUser = Session["UID"].ToString() + " "  + Login_Name;
                string s_par_Vendor = SLP_Vendor.Text + " " + SLP_Vendor.Name;
                string s_par_RootNo = SLP_RootNo_S.Text + " " + SLP_RootNo_S.Name +" ~ " + SLP_RootNo_E.Text + " " + SLP_RootNo_E.Name;
                string s_par_PMA = SLP_PMA_S.Text + " " + SLP_PMA_S.Name + " ~ " + SLP_PMA_E.Text + " " + SLP_PMA_E.Name;
                string s_par_Category = SLP_Category_S.Text + " " + SLP_Category_S.Name + " ~ " + SLP_Category_E.Text + " " + SLP_Category_E.Name;
                string s_par_SortOut = SLP_SortOut_S.Text + " " + SLP_SortOut_S.Name + " ~ " + SLP_SortOut_E.Text + " " + SLP_SortOut_E.Name;
                string s_par_Item = SLP_SKU.Text + " " + SLP_SKU.Name;
                string s_par_Period = SLP_ItemPeriod.Text;
                string s_par_PeriodCount = SLP_SLPNumber.Text;
                string s_par_Order ="";

                if ( ddl_Order.SelectedValue=="1"){
                    s_par_Order = "期別降冪";
                }
                else if ( ddl_Order.SelectedValue=="2"){
                    s_par_Order = "期別升冪";
                }
               
                report.SetParameterValue("par_Program_ID", s_par_Program_ID);
                report.SetParameterValue("par_LoginUser", s_par_LoginUser);
                report.SetParameterValue("par_Vendor", s_par_Vendor);
                report.SetParameterValue("par_RootNo", s_par_RootNo);
                report.SetParameterValue("par_PMA", s_par_PMA);
                report.SetParameterValue("par_Category", s_par_Category);
                report.SetParameterValue("par_SortOut", s_par_SortOut);
                report.SetParameterValue("par_Item", s_par_Item);
                report.SetParameterValue("par_Period", s_par_Period);
                report.SetParameterValue("par_PeriodCount", s_par_PeriodCount);
                report.SetParameterValue("par_Order", s_par_Order);

                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                break;
            default:
                break;
        }
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:78,代码来源:MKT111.aspx.cs

示例3: ShowReportA


//.........这里部分代码省略.........

            if (((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text == "ALL")
                report.SetParameterValue("par_Tax_Type_B", "全部");
            else
                report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
            //report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
        }
        else if (V_RPT == "VAM123R")
        {
            FileName = "進項憑證明細表(發票與折讓)";
            report.SetParameterValue("par_Program_ID", V_RPT);
            report.SetParameterValue("par_Program_ID_B", V_RPT);

            report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
            report.SetParameterValue("par_LoginUser_B", Session["UID"].ToString() + Login_Name);

            if (this.SLP_SLPDateRange.StartDate.ToString() == "" && this.SLP_SLPDateRange.EndDate.ToString() == "")
            {
                report.SetParameterValue("par_Source_date", "全部");
                report.SetParameterValue("par_Source_date_B", "全部");
            }
            else
            {
                report.SetParameterValue("par_Source_date", this.SLP_SLPDateRange.StartDate.ToString() + "-" + this.SLP_SLPDateRange.EndDate.ToString());
                report.SetParameterValue("par_Source_date_B", this.SLP_SLPDateRange.StartDate.ToString() + "-" + this.SLP_SLPDateRange.EndDate.ToString());
            }

            if (this.SLP_SLPDateRange1.StartDate.ToString() == "" && this.SLP_SLPDateRange1.EndDate.ToString() == "")
            {
                report.SetParameterValue("par_Keyin_date", "全部");
                report.SetParameterValue("par_Keyin_date_B", "全部");
            }
            else
            {
                report.SetParameterValue("par_Keyin_date", this.SLP_SLPDateRange1.StartDate.ToString() + "-" + this.SLP_SLPDateRange1.EndDate.ToString());
                report.SetParameterValue("par_Keyin_date_B", this.SLP_SLPDateRange1.StartDate.ToString() + "-" + this.SLP_SLPDateRange1.EndDate.ToString());
            }


            if (this.SLP_VendorBase1.Text.Trim() == "" && this.SLP_VendorBase2.Text.Trim() == "")
            {
                report.SetParameterValue("par_Vandor", "全部");
                report.SetParameterValue("par_Vandor_B", "全部");
            }
            else
            {
                report.SetParameterValue("par_Vandor", this.SLP_VendorBase1.Text.Trim() + "-" + this.SLP_VendorBase2.Text.Trim());
                report.SetParameterValue("par_Vandor_B", this.SLP_VendorBase1.Text.Trim() + "-" + this.SLP_VendorBase2.Text.Trim());
            }

            if (((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text == "ALL")
            {
                report.SetParameterValue("par_Tax_Type", "全部");
                report.SetParameterValue("par_Tax_Type_B", "全部");
            }
            else
            {
                report.SetParameterValue("par_Tax_Type", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
                report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
            }

        }




        //檔案匯出
        if (V_FORM_TYPE == "XLS")
        {
            System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
            byte[] bytesXLS = new byte[streamXLS.Length];
            streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
            streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
            //Export File  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName + ".XLS", System.Text.Encoding.UTF8));//匯出檔名  
            Response.ContentType = "application/xls";
            Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
            Response.Flush();
            Response.Close();
        }
        else
        {
            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
            //Export File  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName + ".PDF", System.Text.Encoding.UTF8));//匯出檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        report.Close();
        #endregion
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:VAM121.aspx.cs

示例4: LoadCrystalReport

    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);


        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;

        #region 前置檢查與參數過濾

        string par_S_PDate = this.SLP_SLPDateRange.StartDate;
        string par_E_PDate = this.SLP_SLPDateRange.EndDate;
        string par_BatchNo = this.txtBatchNo.Text;
        string par_ChanNo = this.SLP_StoreChain.Text + " " + this.SLP_StoreChain.Name;
        string par_ChanSourceNo = this.txtChanSourceNo.Text;
        string par_S_SignDate = this.SLP_SignDate.StartDate;
        string par_E_SignDate = this.SLP_SignDate.EndDate;
        string par_Item = this.SLP_SKU.Text + " " + this.SLP_SKU.Name;
        string par_Period = this.SLP_ItemPeriod.Text + " " + this.SLP_ItemPeriod.Name;
        string par_ItemMap = this.txtItemMap.Text;

        par_ProgramID = this.PageCode;
        par_LoginUser = Session["UID"].ToString();
        #endregion


        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

        returnList.Clear();

        report.SetParameterValue("par_S_PDate", par_S_PDate);
        report.SetParameterValue("par_E_PDate", par_E_PDate);
        report.SetParameterValue("par_BatchNo", par_BatchNo);
        report.SetParameterValue("par_ChanNo", par_ChanNo);
        report.SetParameterValue("par_ChanSourceNo", par_ChanSourceNo);
        report.SetParameterValue("par_S_SignDate", par_S_SignDate);
        report.SetParameterValue("par_E_SignDate", par_E_SignDate);
        report.SetParameterValue("par_Item", par_Item);
        report.SetParameterValue("par_Period", par_Period);
        report.SetParameterValue("par_ItemMap", par_ItemMap);

        report.SetParameterValue("par_ProgramID", par_ProgramID);
        report.SetParameterValue("par_LoginUser", par_LoginUser);
        #endregion

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

                Response.ContentType = "application/vnd.ms-excel";

                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();

                break;
            case "PDF":
                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                break;
            default:

                break;
        }

    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:100,代码来源:VGR051.aspx.cs

示例5: LoadCrystalReport

    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;

        #region 前置檢查與參數過濾

        string par_S_Vendor = this.SLP_VendorBaseS.Text + " " + this.SLP_VendorBaseS.Name;
        string par_E_Vendor = this.SLP_VendorBaseE.Text + " " + this.SLP_VendorBaseE.Name;
        string par_S_PMA = this.SLP_PMAS.Text + " " + this.SLP_PMAS.Name;
        string par_E_PMA = this.SLP_PMAE.Text + " " + this.SLP_PMAE.Name;
        string par_S_RootNo = this.SLP_RootNoS.Text + " " + this.SLP_RootNoS.Name;
        string par_E_RootNo = this.SLP_RootNoE.Text + " " + this.SLP_RootNoE.Name;

        string par_S_LocateNo = this.SLP_SimpleLocateSec1.Text1 + " " + this.SLP_SimpleLocateSec1.Name;
        string par_E_LocateNo = this.SLP_SimpleLocateSec2.Text1 + " " + this.SLP_SimpleLocateSec2.Name;
        string par_S_LocateSec = SLP_SimpleLocateSec1.Text2.Trim() != "" ? this.SLP_SimpleLocateSec1.Text1 + SLP_SimpleLocateSec1.Text2 : "";
        string par_E_LocateSec = SLP_SimpleLocateSec2.Text2.Trim() != "" ? this.SLP_SimpleLocateSec2.Text1 + SLP_SimpleLocateSec2.Text2 : "";

        string par_Item = this.SLP_SKU.Text + " " + this.SLP_SKU.Name;
        string par_Period = this.SLP_ItemPeriod.Text + " " + this.SLP_ItemPeriod.Name;

        par_ProgramID = this.PageCode;
        par_LoginUser = Session["UID"].ToString();
        #endregion

        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

        returnList.Clear();

        report.SetParameterValue("par_S_Vendor", par_S_Vendor);
        report.SetParameterValue("par_E_Vendor", par_E_Vendor);
        report.SetParameterValue("par_S_PMA", par_S_PMA);
        report.SetParameterValue("par_E_PMA", par_E_PMA);
        report.SetParameterValue("par_S_RootNo", par_S_RootNo);
        report.SetParameterValue("par_E_RootNo", par_E_RootNo);

        report.SetParameterValue("par_S_LocateNo", par_S_LocateNo);
        report.SetParameterValue("par_E_LocateNo", par_E_LocateNo);
        report.SetParameterValue("par_S_LocateSec", par_S_LocateSec);
        report.SetParameterValue("par_E_LocateSec", par_E_LocateSec);

        report.SetParameterValue("par_Item", par_Item);
        report.SetParameterValue("par_Period", par_Period);

        report.SetParameterValue("par_ProgramID", par_ProgramID);
        report.SetParameterValue("par_LoginUser", par_LoginUser);
        #endregion

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

                Response.ContentType = "application/vnd.ms-excel";

                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();

                break;
            case "PDF":

                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
//.........这里部分代码省略.........
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:VGR031.aspx.cs

示例6: LoadCrystalReport

    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";


                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();

                break;
            case "PDF":

                //string s_par_Program_ID = this.PageCode;
                string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();

                string s_par_Program_ID = "MKT10";
                string s_par_LoginUser = Session["UID"].ToString() + Login_Name;
                string s_par_Busdate = SLP_MDC_START_DATE.StartDate + " ~ " + SLP_MDC_START_DATE.EndDate;
                string s_par_Z_O = SLP_Z_O_S.Text + "   " + SLP_Z_O_S.Name + " ~ " + SLP_Z_O_E.Text + "   " + SLP_Z_O_E.Name;
                string s_par_Chan_No = SLP_CHAIN_S.Text + "   " + SLP_CHAIN_S.Name + " ~ " + SLP_CHAIN_E.Text + "   " + SLP_CHAIN_E.Name;

                report.SetParameterValue("par_Program_ID", s_par_Program_ID);
                report.SetParameterValue("par_LoginUser", s_par_LoginUser);
                report.SetParameterValue("par_Busdate", s_par_Busdate);
                report.SetParameterValue("par_Z_O", s_par_Z_O);
                report.SetParameterValue("par_Chan_No", s_par_Chan_No);

                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                break;
            default:

                break;
        }
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:67,代码来源:MKT101.aspx.cs

示例7: LoadCrystalReport

    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);


        string par_ChanNo = string.Empty;
        string par_Store = string.Empty;

        #region 前置檢查與參數過濾

        par_ChanNo = Server.UrlDecode(Request.QueryString["Chan"].ToString());
        par_Store = Server.UrlDecode(Request.QueryString["Store"].ToString());
        #endregion


        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

        returnList.Clear();

        report.SetParameterValue("ChanNo", par_ChanNo);
        report.SetParameterValue("Store", par_Store);

        #endregion


        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                Response.ContentType = "application/vnd.ms-excel";


                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            case "PDF":


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();

                break;
            default:

                break;
        }

    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:86,代码来源:POP_VGR024_2.aspx.cs

示例8: LoadCrystalReport

    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        string s_par_Program_ID = string.Empty;
        string s_par_LoginUser = string.Empty;
        string s_par_LoginName = string.Empty;
        string s_par_1 = string.Empty;
        string s_par_2 = string.Empty;
        string s_par_3 = string.Empty;

        s_par_Program_ID = this.PageCode;
        s_par_LoginUser = Session["UID"].ToString();
        s_par_LoginName = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();
        s_par_1 = SLP_PICK_DATE.StartDate + " ~ " + SLP_PICK_DATE.EndDate;
        s_par_2 = ddlLineStart.Text + " ~ " + ddlLineEnd.Text;
        s_par_3 = txtSTATION_NO_S.Text + " ~ " + txtSTATION_NO_E.Text;

        report.SetParameterValue("par_Program_ID", s_par_Program_ID);
        report.SetParameterValue("par_LoginUser", s_par_LoginUser);
        report.SetParameterValue("par_LoginName", s_par_LoginName);
        report.SetParameterValue("par_1", s_par_1);
        report.SetParameterValue("par_2", s_par_2);
        report.SetParameterValue("par_3", s_par_3);
        report.SetParameterValue("par_Type", reportFormatType);

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

                Response.ContentType = "application/vnd.ms-excel";

                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();

                break;
            case "PDF":            

                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                break;
            default:

                break;
        }

    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:80,代码来源:CGD341.aspx.cs

示例9: ShowReport

    private void ShowReport(DataTable Dt)
    {
        try
        {
            string s_par_Program_ID = string.Empty;
            string s_par_LoginUser = string.Empty;

            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            report.Load(Server.MapPath("./REPORT/INV021R0" + rblREPORT.SelectedValue + ".rpt"));
            report.SetDataSource(Dt);

            DataTable userName = (DataTable)Session["UserInfo"];
            string UName = userName.Rows[0]["Name"].ToString();

            report.SetParameterValue("par_Program_ID", this.PageCode);
            report.SetParameterValue("par_LoginUser", Session["UID"].ToString());
            report.SetParameterValue("par_LoginUser_Name", UName);

            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
            //Export File  
            Response.ClearContent();
            Response.ClearHeaders();

            string rpt_name = "";
            if (rblREPORT.SelectedValue == "1")
                rpt_name = "儲區庫存匯總表_" + DateTime.Now.ToString("yyyyMMdd") + ".PDF";
            else
                rpt_name = "儲位庫存明細表_" + DateTime.Now.ToString("yyyyMMdd") + ".PDF";
            Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(rpt_name, System.Text.Encoding.UTF8));//匯出檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);

            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:44,代码来源:INV021.aspx.cs

示例10: LoadCrystalReport

    /// <summary>
    /// 利用 CrystalReport 列印報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);


        #region 取得各輸入值

        string s_par_Program_ID = string.Empty;
        string s_par_LoginUser = string.Empty;
        string s_par_ST_Accept_Date = string.Empty;
        string s_par_Trans_No_S = string.Empty;
        string s_par_Trans_No_E = string.Empty;
        string s_par_Trans_Vendor_S = string.Empty;
        string s_par_Trans_Vendor_E = string.Empty;
        string s_par_Route_S = string.Empty;
        string s_par_Route_E = string.Empty;
        string s_par_StoreChain_S = string.Empty;
        string s_par_StoreChain_E = string.Empty;
        string s_par_Report = string.Empty;


        s_par_Program_ID = this.PageCode;
        s_par_LoginUser = Session["UID"].ToString();
        s_par_ST_Accept_Date = SLP_SLPDate.Text;
        s_par_Trans_No_S = SLP_Trans_No_S.Text + " " + ((DropDownList)SLP_Trans_No_S.FindControl("D1")).SelectedItem.Text;
        s_par_Trans_No_E = SLP_Trans_No_E.Text + " " + ((DropDownList)SLP_Trans_No_E.FindControl("D1")).SelectedItem.Text;
        s_par_Trans_Vendor_S = SLP_Trans_Vendor_S.Text + " " + ((DropDownList)SLP_Trans_Vendor_S.FindControl("D1")).SelectedItem.Text;
        s_par_Trans_Vendor_E = SLP_Trans_Vendor_E.Text + " " + ((DropDownList)SLP_Trans_Vendor_E.FindControl("D1")).SelectedItem.Text;

        if (((TextBox)SLP_Route_S.FindControl("TextBoxCode")).Text != "")
        {
            s_par_Route_S = ((TextBox)SLP_Route_S.FindControl("TextBoxCode")).Text + " " + Request[SLP_Route_S.TextBox_Name.UniqueID].ToString();
        }
        else
        {
            s_par_Route_S = "";
        }

        if (((TextBox)SLP_Route_E.FindControl("TextBoxCode")).Text != "")
        {
            s_par_Route_E = ((TextBox)SLP_Route_E.FindControl("TextBoxCode")).Text + " " + Request[SLP_Route_E.TextBox_Name.UniqueID].ToString();
        }
        else
        {
            s_par_Route_E = "";
        }

        if (((TextBox)SLP_StoreChain_S.FindControl("TextBoxCode")).Text != "")
        {
            s_par_StoreChain_S = ((TextBox)SLP_StoreChain_S.FindControl("TextBoxCode")).Text + " " + Request[SLP_StoreChain_S.TextBox_Name.UniqueID].ToString(); 
        }
        else
        {
            s_par_StoreChain_S = "";
        }

        if (((TextBox)SLP_StoreChain_E.FindControl("TextBoxCode")).Text != "")
        {
            s_par_StoreChain_E = ((TextBox)SLP_StoreChain_E.FindControl("TextBoxCode")).Text + " " + Request[SLP_StoreChain_E.TextBox_Name.UniqueID].ToString(); 
        }
        else
        {
            s_par_StoreChain_E = "";
        }

        s_par_Report = rblPrintType.SelectedItem.Text;

        #endregion


        report.SetParameterValue("par_Program_ID", s_par_Program_ID);
        report.SetParameterValue("par_LoginUser", s_par_LoginUser);
        report.SetParameterValue("par_ST_Accept_Date", s_par_ST_Accept_Date);
        report.SetParameterValue("par_Trans_No", s_par_Trans_No_S + " ~ " + s_par_Trans_No_E);
        report.SetParameterValue("par_Trans_Vendor", s_par_Trans_Vendor_S + " ~ " + s_par_Trans_Vendor_E);
        report.SetParameterValue("par_Routee", s_par_Route_S + " ~ " + s_par_Route_E);
        report.SetParameterValue("par_StoreChain", s_par_StoreChain_S + " ~ " + s_par_StoreChain_E);
        report.SetParameterValue("par_Report", s_par_Report);


        #region 判斷輸出檔案型態並輸出


        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
//.........这里部分代码省略.........
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:TRN051.aspx.cs

示例11: ShowReport

    /// <summary>
    /// show報表
    /// </summary>
    private void ShowReport(DataTable Dt)
    {
        try
        {
            string strFileName = "";
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            if (TabContainer2.ActiveTabIndex == 0)
            {
                report.Load(Server.MapPath("./REPORT/MKT07/CRMKT07R01.rpt"));
                strFileName = HttpUtility.UrlEncode("PMA(大分類)銷售查詢.PDF", System.Text.Encoding.UTF8);
            }
            if (TabContainer2.ActiveTabIndex == 1)
            {
                report.Load(Server.MapPath("./REPORT/MKT07/CRMKT07R02.rpt"));
                strFileName = HttpUtility.UrlEncode("PMA(中分類)銷售查詢.PDF", System.Text.Encoding.UTF8);
            }
            if (TabContainer2.ActiveTabIndex == 2)
            {
                report.Load(Server.MapPath("./REPORT/MKT07/CRMKT07R03.rpt"));
                strFileName = HttpUtility.UrlEncode("PMA(小分類)銷售查詢.PDF", System.Text.Encoding.UTF8);
            }
            report.SetDataSource(Dt);

            string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();
            report.SetParameterValue("par_Program_ID", "MKT07");
            report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
            report.SetParameterValue("par_StAcceptDate", SLP_MDC_START_DATE.StartDate + "~" + SLP_MDC_START_DATE.EndDate);
            if (TabContainer2.ActiveTabIndex == 0)
            {
                report.SetParameterValue("par_ROOTDate", SLP_ROOT_NO_S.Text + Page.Request.Form[SLP_ROOT_NO_S.TextBox_Name.UniqueID] + "~" + SLP_ROOT_NO_E.Text + Page.Request.Form[SLP_ROOT_NO_E.TextBox_Name.UniqueID]);
                report.SetParameterValue("par_PMADate", SLP_PMA_S.Text + Page.Request.Form[SLP_PMA_S.TextBox_Name.UniqueID] + "~" + SLP_PMA_E.Text + Page.Request.Form[SLP_PMA_E.TextBox_Name.UniqueID]);
            }
            if (TabContainer2.ActiveTabIndex == 1)
            {
                report.SetParameterValue("par_ROOTDate", SLP_ROOT_NO_S.Text + Page.Request.Form[SLP_ROOT_NO_S.TextBox_Name.UniqueID] + "~" + SLP_ROOT_NO_E.Text + Page.Request.Form[SLP_ROOT_NO_E.TextBox_Name.UniqueID]);
                report.SetParameterValue("par_PMADate", SLP_PMA_S.Text + Page.Request.Form[SLP_PMA_S.TextBox_Name.UniqueID] + "~" + SLP_PMA_E.Text + Page.Request.Form[SLP_PMA_E.TextBox_Name.UniqueID]);
                report.SetParameterValue("par_CATEGORYDate", SLP_CATEGORY_S.Text + Page.Request.Form[SLP_CATEGORY_S.TextBox_Name.UniqueID] + "~" + SLP_CATEGORY_E.Text + Page.Request.Form[SLP_CATEGORY_E.TextBox_Name.UniqueID]);
            }
            if (TabContainer2.ActiveTabIndex == 2)
            {
                report.SetParameterValue("par_ROOTDate", SLP_ROOT_NO_S.Text + Page.Request.Form[SLP_ROOT_NO_S.TextBox_Name.UniqueID] + "~" + this.SLP_ROOT_NO_E.Text + Page.Request.Form[SLP_ROOT_NO_E.TextBox_Name.UniqueID]);
                report.SetParameterValue("par_PMADate", SLP_PMA_S.Text + Page.Request.Form[SLP_PMA_S.TextBox_Name.UniqueID] + "~" + SLP_PMA_E.Text + Page.Request.Form[SLP_PMA_E.TextBox_Name.UniqueID]);
                report.SetParameterValue("par_CATEGORYDate", SLP_CATEGORY_S.Text + Page.Request.Form[SLP_CATEGORY_S.TextBox_Name.UniqueID] + "~" + SLP_CATEGORY_E.Text + Page.Request.Form[SLP_CATEGORY_E.TextBox_Name.UniqueID]);
                report.SetParameterValue("par_SORTOUTDate", SLP_SORTOUT_S.Text + Page.Request.Form[SLP_SORTOUT_S.TextBox_Name.UniqueID] + "~" + SLP_SORTOUT_E.Text + Page.Request.Form[SLP_SORTOUT_E.TextBox_Name.UniqueID]);
            }
            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

            //export file  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//pdf檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:68,代码来源:MKT071.aspx.cs

示例12: LoadCrystalReport


//.........这里部分代码省略.........
    //        //AddParameter("par_Program_ID", s_par_Program_ID, pars);
    //        //AddParameter("par_LoginUser", s_par_LoginUser, pars);

    //        this.CrystalReportViewer1.ReportSource = report;

    //        //this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[0]);
    //        //this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[1]);

    //        this.CrystalReportViewer1.Visible = true;


    //        Session["Rpt_Data_1" + PageTimeStamp.Value] = Dt;
    //        Session["ButtonSelect"] = "ShowReport";
    //    }
    //    catch (Exception ex)
    //    {
    //        ErrorMsgLabel.Text = ex.Message;
    //    }
    //    finally { }
    //}

    /// <summary>
    /// Show未列印報表
    /// </summary>
    /// <param name="Dt"></param>
    //private void ShowUnprintReport(DataTable Dt)
    //{
    //    try
    //    {
    //        string s_par_Program_ID = string.Empty;
    //        string s_par_LoginUser = string.Empty;

    //        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

    //        report.Load(Server.MapPath("./REPORT/CGD251R02.rpt"));

    //        report.SetDataSource(Dt);

    //        s_par_Program_ID = this.PageCode;
    //        s_par_LoginUser = Session["UID"].ToString();

    //        ParameterFields pars = new ParameterFields();
    //        AddParameter("par_Program_ID", s_par_Program_ID, pars);
    //        AddParameter("par_LoginUser", s_par_LoginUser, pars);

    //        this.CrystalReportViewer1.ReportSource = report;

    //        this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[0]);
    //        this.CrystalReportViewer1.ParameterFieldInfo.Add(pars[1]);

    //        this.CrystalReportViewer1.Visible = true;


    //        Session["Rpt_Data_2" + PageTimeStamp.Value] = Dt;
    //        Session["ButtonSelect"] = "ShowUnprintReport";
    //    }
    //    catch (Exception ex)
    //    {
    //        ErrorMsgLabel.Text = ex.Message;
    //    }
    //    finally { }
    //}

    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable Dt)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(Dt);

        string s_par_Program_ID = this.PageCode;
        string s_par_LoginUser = Session["UID"].ToString();

        this.CrystalReportViewer1.ReportSource = report;

        report.SetParameterValue("par_Program_ID", s_par_Program_ID);
        report.SetParameterValue("par_LoginUser", s_par_LoginUser);

        System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, bytes.Length);
        stream.Seek(0, System.IO.SeekOrigin.Begin);

        //export file  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

        Response.ContentType = "application/vnd.ms-excel";

        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.Flush();
        Response.Close();
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:CGD251.aspx.cs

示例13: LoadCrystalReport

    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);


        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;

        #region 前置檢查與參數過濾

        DropDownList ddlCodeFile1 = (DropDownList)(this.SLP_CodeFile1.FindControl("D1"));
        string V_LOCATE_NO = this.SLP_CodeFile1.Text + " " + ddlCodeFile1.SelectedItem.Text;
        string V_LOCATE_SECTOR_S = this.ddlS.Text;
        string V_LOCATE_SECTOR_E = this.ddlE.Text;
        par_ProgramID = this.PageCode;
        par_LoginUser = Session["UID"].ToString() + " " + Get_LoginName();
        #endregion


        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

        returnList.Clear();

        report.SetParameterValue("V_LOCATE_NO", V_LOCATE_NO);
        report.SetParameterValue("V_LOCATE_SECTOR_S", V_LOCATE_SECTOR_S);
        report.SetParameterValue("V_LOCATE_SECTOR_E", V_LOCATE_SECTOR_E);

        report.SetParameterValue("par_Program_ID", par_ProgramID);
        report.SetParameterValue("par_LoginUser", par_LoginUser);

        #endregion


        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                Response.ContentType = "application/vnd.ms-excel";


                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            case "PDF":


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();

                break;
            default:

                break;
        }

    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:94,代码来源:IVM081.aspx.cs

示例14: ShowReportDB

    private void ShowReportDB(DataTable dt, int iMaxTarget, int iMaxSubsidy)
    {
        #region 利用CrystalReport列印報表

        //使用者名稱
        DataTable dt1 = new DataTable();
        dt1 = (DataTable)Session["UserInfo"];
        string Login_Name = dt1.Rows[0]["Name"].ToString();

        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        if (this.rdoType4.Checked)
            report.Load(Server.MapPath("./REPORT/VAM131/VAM131R04B.rpt"));
        else
            report.Load(Server.MapPath("./REPORT/VAM131/VAM131R05B.rpt"));

        DataTable dtR = new DataTable();
        dtR = this.MakeDTForRptD();
        string[] arrField, arrField1;
        arrField = new string[10] { "獎勵金一", "獎勵金二", "獎勵金三", "獎勵金四", "獎勵金五", "獎勵金六", "獎勵金七", "獎勵金八", "獎勵金九", "獎勵金十" };
        arrField1 = new string[10] { "物流費一", "物流費二", "物流費三", "物流費四", "物流費五", "物流費六", "物流費七", "物流費八", "物流費九", "物流費十" };

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow drA = dtR.NewRow();
            drA[0] = dt.Rows[i][0].ToString();
            drA[1] = dt.Rows[i][1].ToString();
            if (dt.Rows[i][2].ToString() != "")
            {
                if (this.rdoType4.Checked)
                    drA[2] = Convert.ToDateTime(dt.Rows[i][2].ToString()).ToShortDateString();
                else
                    drA[2] = dt.Rows[i][2].ToString();
            }
            drA[3] = Convert.ToDecimal(dt.Rows[i][3].ToString());
            drA[4] = Convert.ToDecimal(dt.Rows[i][4].ToString());
            drA[5] = Convert.ToDecimal(dt.Rows[i][5].ToString());
            drA[6] = Convert.ToDecimal(dt.Rows[i][6].ToString());
            drA[7] = Convert.ToDecimal(dt.Rows[i][7].ToString());
            for (int j = 0; j < iMaxTarget; j++)
            {
                drA[8 + j] = Convert.ToDecimal(dt.Rows[i][8 + j].ToString());
            }

            for (int k = 0; k < iMaxSubsidy; k++)
            {
                drA[8 + iMaxTarget + k] = Convert.ToDecimal(dt.Rows[i][18 + k].ToString());
            }
            drA[8 + iMaxTarget + iMaxSubsidy] = Convert.ToDecimal(dt.Rows[i][28].ToString());

            for (int l = 29; l < 29 + iMaxTarget; l++)
            {
                if (dt.Rows[i][l].ToString() != "")
                    drA[l] = arrField[l - 29] + ":" + dt.Rows[i][l].ToString();
                else
                    drA[l] = dt.Rows[i][l].ToString();
            }
            dtR.Rows.Add(drA);
        }


        report.SetDataSource(dtR);

        for (int j = 0; j < iMaxTarget; j++)
        {
            report.SetParameterValue("par_Field" + Convert.ToString(9 + j), arrField[j]);
        }

        for (int j = 0; j < iMaxSubsidy; j++)
        {
            report.SetParameterValue("par_Field" + Convert.ToString(9 + iMaxTarget + j), arrField1[j]);
        }


        report.SetParameterValue("par_Field" + Convert.ToString(9 + iMaxTarget + iMaxSubsidy), "未稅金額");

        for (int j = 0; j < 20 - (iMaxTarget + iMaxSubsidy); j++)
        {
            report.SetParameterValue("par_Field" + Convert.ToString(10 + iMaxTarget + iMaxSubsidy + j), "");
        }

        //this.CryView.ReportSource = report;
        //檔案匯出
        System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        byte[] bytesXLS = new byte[streamXLS.Length];
        streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
        streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("停止往來及合約追溯彙總表_" + System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + ".XLS", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/xls";
        Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
        Response.Flush();
        Response.Close();
        report.Close();

        #endregion
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:98,代码来源:VAM131.aspx.cs

示例15: ShowReport

    private void ShowReport(DataTable dt,string V_FORM_TYPE,DateTime D_START_DATE,DateTime D_END_DATE,String V_ADJ_IN_DESC,String V_ADJ_OUT_DESC)
    {
        #region 利用CrystalReport列印報表

        //使用者名稱
        DataTable dt1 = new DataTable();
        dt1 = (DataTable)Session["UserInfo"];
        string Login_Name = dt1.Rows[0]["Name"].ToString();

        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(Server.MapPath("./REPORT/PSS031/PSS031R01.rpt"));
        report.SetDataSource(dt);
        report.SetParameterValue("par_Program_ID", "PSS031R");
        report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
        report.SetParameterValue("par_YEAR_MONTH", this.SLP_YearMonth1.Text.Trim());

        if (rblRptType.Items[0].Selected)
            report.SetParameterValue("par_TYPE", "差異");
        else
            report.SetParameterValue("par_TYPE", "全部");

        if (this.SLP_SKU_B.Text.Trim() == "" && this.SLP_SKU_E.Text.Trim() == "")
        {
            report.SetParameterValue("par_ITEM", "全部");
        }
        else
        {
            report.SetParameterValue("par_ITEM", this.SLP_SKU_B.Text.Trim() + "~" + this.SLP_SKU_E.Text.Trim());
        }

        if (this.SLP_ItemPeriod_B.Text.Trim() == "" && this.SLP_ItemPeriod_E.Text.Trim() == "")
        {
            report.SetParameterValue("par_PERIOD", "全部");
        }
        else
        {
            report.SetParameterValue("par_PERIOD", this.SLP_ItemPeriod_B.Text.Trim() + "~" + this.SLP_ItemPeriod_E.Text.Trim());
        }

        if (this.slp_TAX_TYPE.Text.Trim() == "" )
        {
            report.SetParameterValue("par_TAX_TYPE", "全部");
        }
        else if (this.slp_TAX_TYPE.Text.Trim() == "0")
        {
            report.SetParameterValue("par_TAX_TYPE", "應稅");
        }
        else if (this.slp_TAX_TYPE.Text.Trim() == "1")
        {
            report.SetParameterValue("par_TAX_TYPE", "免稅");
        }
        else if (this.slp_TAX_TYPE.Text.Trim() == "2")
        {
            report.SetParameterValue("par_TAX_TYPE", "零稅");
        }

        report.SetParameterValue("par_START_DATE", D_START_DATE);

        report.SetParameterValue("par_END_DATE", D_END_DATE);

        report.SetParameterValue("par_ADJ_IN_DESC", V_ADJ_IN_DESC);

        report.SetParameterValue("par_ADJ_OUT_DESC", V_ADJ_OUT_DESC);
        
       
        
        //檔案匯出
        if (V_FORM_TYPE == "XLS")
        {
            System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
            byte[] bytesXLS = new byte[streamXLS.Length];
            streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
            streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
            //Export File  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("進銷存差異明細表.XLS", System.Text.Encoding.UTF8));//匯出檔名  
            Response.ContentType = "application/xls";
            Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
            Response.Flush();
            Response.Close();
        }
        else
        {
            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
            //Export File  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("進銷存差異明細表.PDF", System.Text.Encoding.UTF8));//匯出檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        report.Close();
        #endregion
//.........这里部分代码省略.........
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:PSS031.aspx.cs


注:本文中的CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。