예제 #1
1
        public Boolean printReport(CrystalDecisions.CrystalReports.Engine.ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param1, String ParamName1, String param2, String ParamName2)
        {
            if (PrinterName=="none") return false;

            paramField.ParameterFieldName = ParamName1;
            discreteVal.Value = param1;
            paramField.CurrentValues.Add (discreteVal);
            paramFields.Add (paramField);
            crReport.DataDefinition.ParameterFields[0].CurrentValues.Add (discreteVal);

            paramField2.ParameterFieldName = ParamName2;
            discreteVal2.Value = param2;
            paramField2.CurrentValues.Add (discreteVal2);
            paramFields.Add (paramField2);
            crReport.DataDefinition.ParameterFields[1].CurrentValues.Add (discreteVal2);

            CrystalReportViewer1.ReportSource = crReport;
            CrystalReportViewer1.ParameterFieldInfo = paramFields;
            CrystalReportViewer1.RefreshReport();

            ParameterValues tmpParam = new ParameterValues();
            ParameterValues tmpParam2 = new ParameterValues();
            tmpParam.Add(discreteVal);
            tmpParam2.Add(discreteVal2);
            crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(tmpParam);
            crReport.DataDefinition.ParameterFields[1].ApplyCurrentValues(tmpParam2);
            crReport.PrintOptions.PrinterName = PrinterName;
            //			crReport.PrintToPrinter(1,false,1,1);
            crReport.PrintToPrinter(1,false,1,99);

            //Response.write (PrinterName);
            return true;
        }
예제 #2
0
 public ShowReports(BillingReport1 billrpt,CrystalDecisions.Shared.ParameterFields parafield)
 {
     billingreport = true;
     InitializeComponent();
     billreport = billrpt;
     para = parafield;
 }
예제 #3
0
 public ShowReports(BilledProducts billprods,CrystalDecisions.Shared.ParameterFields parfields)
 {
     billedprods = true;
     billedproduct = billprods;
     para = parfields;
     InitializeComponent();
 }
예제 #4
0
 public bool ShowReport(string[] reportTitle, string[] reportData, DataTable dataTbl,
                         CrystalDecisions.CrystalReports.Engine.ReportClass myReport)
 {
     try
     {
         //==============================
         //  Make report
         //==============================
         if (this.ExportOutput != Export.ExportFormat.None)
             this.ExportData(dataTbl, this.ExportOutput);
         else
         {
             myReport.SetDataSource(dataTbl);
             reportViewer.SetReportPara(myReport.ParameterFields, reportTitle, "reportTitle");
             reportViewer.SetReportPara(myReport.ParameterFields, reportData, "reportData");
             reportViewer.ShowReport(myReport);
             myReport.Dispose();
         }
     }
     catch (Exception er)
     {
         common.errorHandler.lastErrorMessage = er.Message.ToString();
         return false;
     }
     return true;
 }
예제 #5
0
        protected void Login(CrystalDecisions.CrystalReports.Engine.ReportDocument report)
        {
            string serverName = ConfigurationManager.AppSettings["OraData"];
            string userId = ConfigurationManager.AppSettings["User"];

            string passWord = ConfigurationManager.AppSettings["Password"];

            //Set Database Logon to main report
            foreach (CrystalDecisions.Shared.IConnectionInfo connection in report.DataSourceConnections)
            {
                if (connection.ServerName == serverName)
                {
                    connection.SetLogon(userId, passWord);
                }
            }

            //Set Database Logon to subreport
            foreach (CrystalDecisions.CrystalReports.Engine.ReportDocument subreport in report.Subreports)
            {
                foreach (CrystalDecisions.Shared.IConnectionInfo connection in subreport.DataSourceConnections)
                {
                    if (connection.ServerName == serverName)
                    {
                        connection.SetLogon(userId, passWord);
                    }
                }
            }
        }
예제 #6
0
            public static string GenerateExport(CrystalDecisions.CrystalReports.Engine.ReportDocument selectedReport, CrystalDecisions.Shared.ExportFormatType eft, string ExportFileName)
            {
                selectedReport.ExportOptions.ExportFormatType = eft;

                string contentType = "";

                // Make sure asp.net has create and delete permissions in the directory
                string tempDir = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["tempDir"]);
                string tempFileName = string.Concat(Path.GetFileNameWithoutExtension(selectedReport.FileName), ".");
                if (! string.IsNullOrEmpty(ExportFileName))
                {
                    tempFileName = string.Concat(ExportFileName, ".");
                }

                switch (eft)
                {
                    case CrystalDecisions.Shared.ExportFormatType.PortableDocFormat:
                        tempFileName += "pdf";
                        break;
                    case CrystalDecisions.Shared.ExportFormatType.WordForWindows:
                        tempFileName += "doc";
                        break;
                    case CrystalDecisions.Shared.ExportFormatType.Excel:
                        tempFileName += "xls";
                        break;
                    case CrystalDecisions.Shared.ExportFormatType.HTML32:
                    case CrystalDecisions.Shared.ExportFormatType.HTML40:
                        tempFileName += "htm";
                        CrystalDecisions.Shared.HTMLFormatOptions hop = new CrystalDecisions.Shared.HTMLFormatOptions();
                        hop.HTMLBaseFolderName = tempDir;
                        hop.HTMLFileName = tempFileName;
                        selectedReport.ExportOptions.FormatOptions = hop;
                        break;
                }

                CrystalDecisions.Shared.DiskFileDestinationOptions dfo = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                dfo.DiskFileName = Path.Combine(tempDir, tempFileName);
                selectedReport.ExportOptions.DestinationOptions = dfo;
                selectedReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;

                selectedReport.Export();
                selectedReport.Close();

                string tempFileNameUsed;
                if (eft == CrystalDecisions.Shared.ExportFormatType.HTML32 || eft == CrystalDecisions.Shared.ExportFormatType.HTML40)
                {
                    string[] fp = selectedReport.FilePath.Split("\\" .ToCharArray());
                    string leafDir = fp[fp.Length - 1];
                    // strip .rpt extension
                    leafDir = leafDir.Substring(0, leafDir.Length - 4);
                    tempFileNameUsed = string.Format("{0}{1}\\{2}", tempDir, leafDir, tempFileName);
                }
                else
                {
                    tempFileNameUsed = Path.Combine(tempDir, tempFileName);
                }

                return tempFileNameUsed;
            }
예제 #7
0
 private string getContentType(CrystalDecisions.Shared.ExportFormatType type)
 {
     if (type == ExportFormatType.PortableDocFormat) { return "application/pdf"; }
     else if (type == ExportFormatType.Excel) { return "application/vnd.ms-excel"; }
     else if (type == ExportFormatType.RichText) { return "application/rtf"; }
     else if (type == ExportFormatType.WordForWindows) { return "application/vnd.ms-word"; }
     return "text/html";
 }
예제 #8
0
        public frmPrinter(DataTable dtDatos, CrystalDecisions.CrystalReports.Engine.ReportDocument oReporte, string cTitulo)
        {
            _Datos = dtDatos;
            _Reporte = oReporte;
            _Titulo = cTitulo;

            InitializeComponent();
        }
 private void SetDBLogonForReport(CrystalDecisions.Shared.ConnectionInfo connectionInfo, CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument)
 {
     Tables tables = reportDocument.Database.Tables;
     foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
     {
         TableLogOnInfo tableLogonInfo = table.LogOnInfo;
         tableLogonInfo.ConnectionInfo = connectionInfo;
         table.ApplyLogOnInfo(tableLogonInfo);
     }
 }
예제 #10
0
    protected void crvReportViewer_ReportRefresh(object source, CrystalDecisions.Web.ViewerEventArgs e)
    {
        ParameterDiscreteValue objDiscreteValue;
        ParameterField objParameterField;

        objDiscreteValue = new ParameterDiscreteValue();
        objDiscreteValue.Value = int.Parse(ddlYear.SelectedValue.ToString());
        objParameterField = crvReportViewer.ParameterFieldInfo["year"];
        objParameterField.CurrentValues.Add(objDiscreteValue);
        crvReportViewer.ParameterFieldInfo.Add(objParameterField);
    }
 private void crystalReportViewer1_ReportRefresh(object source, CrystalDecisions.Windows.Forms.ViewerEventArgs e)
 {
     ParameterFields campos = new ParameterFields();
     ParameterField nombreEDS = new ParameterField();
     ParameterDiscreteValue value = new ParameterDiscreteValue();
     nombreEDS.Name = "EDS_NOMBRE";
     nombreEDS.ParameterValueType = ParameterValueKind.StringParameter;
     value.Value = Exportador_Ventas_ServP.Properties.Settings.Default.nombreEDS;
     nombreEDS.DefaultValues.Add(value);
     nombreEDS.CurrentValues.Add(value);
     this.crystalReportViewer1.ParameterFieldInfo.Add(nombreEDS);
 }
예제 #12
0
 public frmBaoCaorpt(CrystalDecisions.CrystalReports.Engine.ReportClass report, string path, Report.ExportCrystalReport.TypeBC type)
 {
     CongTy();
     try
     {
         report.SetParameterValue("TenCongTy", CT.TenCongTy);
         report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
         report.SetParameterValue("DienThoai", CT.SoDienThoai);
         report.SetParameterValue("FaxCongTy", CT.Fax);
         report.SetParameterValue("Web", CT.Website);
         report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
         report.SetParameterValue("Email", CT.Email);
         bool tv = new GUI.Report.ExportCrystalReport().Export(report, path, type);
     }
     catch { }
 }
예제 #13
0
파일: frmSGMReport.cs 프로젝트: tuanly/SGM
 public void HideTabs(CrystalDecisions.Windows.Forms.CrystalReportViewer viewer)
 {
     foreach (Control control in viewer.Controls)
     {
         if (control is PageView)
         {
             if (((PageView)control).Controls.Count > 0)
             {
                 TabControl tab = (TabControl)((PageView)control).Controls[0];
                 tab.ItemSize = new Size(0, 1);
                 tab.SizeMode = TabSizeMode.Fixed;
                 tab.Appearance = TabAppearance.Buttons;
             }
         }
     }
 }
예제 #14
0
 public virtual string GetCustomizedCacheKey(CrystalDecisions.Shared.RequestContext request)
 {
     String key = null;
     // // The following is the code used to generate the default
     // // cache key for caching report jobs in the ASP.NET Cache.
     // // Feel free to modify this code to suit your needs.
     // // Returning key == null causes the default cache key to
     // // be generated.
     //
     // key = RequestContext.BuildCompleteCacheKey(
     //     request,
     //     null,       // sReportFilename
     //     this.GetType(),
     //     this.ShareDBLogonInfo );
     return key;
 }
예제 #15
0
        public static void ExportReport(CrystalDecisions.CrystalReports.Engine.ReportDocument selectedReport, CrystalDecisions.Shared.ExportFormatType eft, HttpResponse TargetResponse, string ExportFileName)
        {
            string contentType = "";
                HttpResponse currentReponse = TargetResponse;
                if (currentReponse == null)
                {
                    currentReponse = HttpContext.Current.Response;
                }
                string tempFileNameUsed = GenerateExport(selectedReport, eft, ExportFileName);

                switch (eft)
                {
                    case ExportFormatType.Excel:
                        contentType = "application/vnd.ms-excel";
                        break;
                    case ExportFormatType.PortableDocFormat:
                        contentType = "application/pdf";
                        break;
                    case ExportFormatType.RichText:
                        contentType = "application/rtf";
                        break;
                    case ExportFormatType.WordForWindows:
                        contentType = "application/doc";
                        break;
                    case ExportFormatType.HTML32:
                        contentType = "application/text";
                        break;
                    case ExportFormatType.HTML40:
                        contentType = "application/text";
                        break;
                }

                currentReponse.ClearContent();
                currentReponse.ClearHeaders();
                currentReponse.ContentType = contentType;
                currentReponse.WriteFile(tempFileNameUsed);
                currentReponse.Flush();
                currentReponse.Close();
                try
                {
                    System.IO.File.Delete(tempFileNameUsed);
                }
                catch (System.Exception)
                {
                }
        }
예제 #16
0
 public void SetReportPara(CrystalDecisions.Shared.ParameterFields paraDef, string[] repoTitles, string prefix)
 {
     CrystalDecisions.Shared.ParameterValues pvCollection = new CrystalDecisions.Shared.ParameterValues();
     CrystalDecisions.Shared.ParameterDiscreteValue pdvHeader = new CrystalDecisions.Shared.ParameterDiscreteValue();
     pvCollection.Clear();
     //Title 
     string tmp;
     for (int idx = 0; idx < repoTitles.Length; idx++)
     {
         tmp = prefix + idx.ToString().Trim();
         if (paraDef[tmp] != null && repoTitles[idx] != null)
         {
             pdvHeader.Value = repoTitles[idx]; pvCollection.Add(pdvHeader);
             paraDef[tmp].CurrentValues = pvCollection;
         }
     }
 }
    protected void crvReportViewer_Navigate(object source, CrystalDecisions.Web.NavigateEventArgs e)
    {
        if (ddlCategoryList.SelectedIndex == 1)
        {
            if (ddlGrade.SelectedIndex > 0)
            {
                ParameterDiscreteValue objDiscreteValue;
                ParameterField objParameterField;

                objDiscreteValue = new ParameterDiscreteValue();
                objDiscreteValue.Value = int.Parse(ddlGrade.SelectedValue.ToString());
                objParameterField = crvReportViewer.ParameterFieldInfo["grade"];
                objParameterField.CurrentValues.Add(objDiscreteValue);
                crvReportViewer.ParameterFieldInfo.Add(objParameterField);

            }

        }
        if (ddlCategoryList.SelectedIndex == 2)
        {
            if (ddlGrade.SelectedIndex > 0)
            {
                if (ddlCategory.SelectedIndex > 0)
                {
                    ParameterDiscreteValue objDiscreteValue, objDiscreteValue2;
                    ParameterField objParameterField, objParameterField2;

                    objDiscreteValue = new ParameterDiscreteValue();
                    objDiscreteValue.Value = int.Parse(ddlGrade.SelectedValue.ToString());
                    objParameterField = crvReportViewer.ParameterFieldInfo["grade"];
                    objParameterField.CurrentValues.Add(objDiscreteValue);
                    crvReportViewer.ParameterFieldInfo.Add(objParameterField);

                    objDiscreteValue2 = new ParameterDiscreteValue();
                    objDiscreteValue2.Value = ddlCategory.SelectedValue.ToString();
                    objParameterField2 = crvReportViewer.ParameterFieldInfo["class"];
                    objParameterField2.CurrentValues.Add(objDiscreteValue2);
                    crvReportViewer.ParameterFieldInfo.Add(objParameterField2);

                }

            }

        }
    }
예제 #18
0
 public frmBaoCaorpt(CrystalDecisions.CrystalReports.Engine.ReportClass report)
 {
     CongTy();
     InitializeComponent();
     try
     {
         crvReport.ReportSource = report;
         report.SetParameterValue("TenCongTy", CT.TenCongTy);
         report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
         report.SetParameterValue("DienThoai", CT.SoDienThoai);
         report.SetParameterValue("FaxCongTy", CT.Fax);
         report.SetParameterValue("Web", CT.Website);
         report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
         report.SetParameterValue("Email", CT.Email);
         crvReport.Show();
     }
     catch { }
 }
예제 #19
0
        // private Logger log;
        public frmPrintPreview(string FormTitle, CrystalDecisions.CrystalReports.Engine.ReportDocument RptDoc, bool pv_bSetContent, bool pv_bDisplayPrintButton)
            : base()
        {
            //This call is required by the Windows Form Designer.
            InitializeComponent();
            log = LogManager.GetCurrentClassLogger();
            //Add any initialization after the InitializeComponent() call
            this.Text = FormTitle;
            this.RptDoc = RptDoc;
            cmdTrinhKy.Visible = pv_bSetContent;
            mv_bSetContent = pv_bSetContent;
            this.crptViewer.ShowRefreshButton = false;
            this.crptViewer.ShowPrintButton = pv_bDisplayPrintButton;

            txtCopyPage.LostFocus += new EventHandler(txtSoCopyPage_LostFocus);
            InitializeEvents();

            CauHinh();
        }
예제 #20
0
 // private Logger log;
  public frmPrintPreview(string FormTitle, CrystalDecisions.CrystalReports.Engine.ReportDocument RptDoc, bool pv_bSetContent,bool pv_bDisplayPrintButton,string TitleReport)
      : base()
  {
      
      //This call is required by the Windows Form Designer.
      InitializeComponent();
      log = LogManager.GetCurrentClassLogger();
      Utility.loadIconToForm(this);
      //Add any initialization after the InitializeComponent() call
      this.Text = FormTitle;
      this.RptDoc = RptDoc;
      this.sTIEUDE = TitleReport;
      
      this.crptViewer.ReportSource = this.RptDoc;
      cmdTrinhKy.Visible = pv_bSetContent;
      mv_bSetContent = pv_bSetContent;
      this.crptViewer.ShowRefreshButton = false;
      this.crptViewer.ShowPrintButton = pv_bDisplayPrintButton;
      InitializeEvents();
      sTIEUDE = new cls_SignInfor().SetTieuDe(RptDoc.ToString(), sTIEUDE);
    
  }
예제 #21
0
        public Boolean printReport(CrystalDecisions.CrystalReports.Engine.ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param, String ParamName)
        {
            bool success=false;
            if (PrinterName!="none")
            {
                try
                {
                    paramField.ParameterFieldName = ParamName;
                    discreteVal.Value = param;
                    paramField.CurrentValues.Add (discreteVal);
                    paramFields.Add (paramField);

                    crReport.DataDefinition.ParameterFields[0].CurrentValues.Add (discreteVal);
                    CrystalReportViewer1.ReportSource = crReport;
                    CrystalReportViewer1.ParameterFieldInfo = paramFields;
                    CrystalReportViewer1.RefreshReport();

                    ParameterValues tmpParam = new ParameterValues();
                    tmpParam.Add(discreteVal);
                    crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(tmpParam);
                    crReport.PrintOptions.PrinterName = PrinterName;
                    //crReport.PrintToPrinter(1,false,1,1);
                    crReport.PrintToPrinter(1,false,1,99);
                    success=true;
                }
                catch{}
            }
            return success;
        }
 protected void CrystalReportViewer1_ViewZoom(object source, CrystalDecisions.Web.ZoomEventArgs e)
 {
     LoadReport();
 }
예제 #23
0
 //thu tuc de gan toan bo thong tin cua doi tuong vao RPT
 public void setValueToRPT(ref CrystalDecisions.CrystalReports.Engine.FieldObject rpt)
 {
     //rpt.ToString = sv_TEN_BIEUBC       'La duy nhat cho 1 file trong CT
     //rpt.Height = mv_CHIEU_RONG      'Do rong cua o text
     //rpt.Width = mv_CHIEU_DAI        'chieu dai cua o text
     //rpt.Top = mv_TOADO_DOC          'toa do docn(y) cua o text
     //rpt.Left = mv_TOADO_NGANG       'toa do ngang cua o text(tinh trong section do)
     //rpt.Text = mv_NOI_DUNG     'Noi dung hien thi
     //don vi
     //ngay thay doi thong tin
     Font ft = null;
     try
     {
         switch (mv_KIEU_CHU.Trim().ToUpper())
         {
             case "CHỮ ĐẬM":
                 ft = new Font(mv_FONT_CHU, mv_CO_CHU, FontStyle.Bold);
                 break;
             case "CHỮ NGHIÊNG":
                 ft = new Font(mv_FONT_CHU, mv_CO_CHU, FontStyle.Italic);
                 break;
             case "BÌNH THƯỜNG":
                 ft = new Font(mv_FONT_CHU, mv_CO_CHU, FontStyle.Regular);
                 break;
             default:
                 ft = new Font(mv_FONT_CHU, mv_CO_CHU, FontStyle.Regular);
                 break;
         }
     }
     catch (Exception ex)
     {
         //font mac dinh
         ft = new Font("Arial", 13, FontStyle.Regular);
     }
     rpt.ApplyFont(ft);
     //Font: cho phep thay doi
 }
예제 #24
0
        //ham nay se thuc hien lay thong tin tu file rpt
        public cls_SignInfor(CrystalDecisions.CrystalReports.Engine.FieldObject rpt, string sv_sDonVi, string baoCao, string pv_sContent)
        {
            exists = false;
            try
            {
                //gan cac thong tin co duoc vao bien
                mv_TEN_BIEUBC = baoCao;
                //rpt.ToString
                mv_TEN_DOITUONG = "txtNguoiKy1";
                mv_FONT_CHU = rpt.Font.Name;
                mv_CO_CHU = (int)rpt.Font.Size;
                switch (rpt.Font.Style)
                {
                    case FontStyle.Bold:
                        mv_KIEU_CHU = "Chữ đậm";
                        break;
                    case FontStyle.Italic:
                        mv_KIEU_CHU = "Chữ nghiêng";
                        break;
                    case FontStyle.Regular:
                        mv_KIEU_CHU = "Bình thường";
                        break;
                    default:
                        mv_KIEU_CHU = "Bình thường";
                        break;
                }
                mv_NOI_DUNG = pv_sContent.Replace("\"", "");
                mv_MA_DVIQLY = sv_sDonVi;
                mv_NGAY_CAPNHAT = new System.DateTime();
            }
            catch (Exception ex)
            {

            }
        }
예제 #25
0
        void SetTrinhky(CrystalDecisions.Shared.ParameterFields p)
        {
            try
            {
                CrystalDecisions.Shared.ParameterFields p0 = new CrystalDecisions.Shared.ParameterFields();
                for (int i = 0; i <= p.Count - 1; i++)
                {
                    if (p[i].ParameterFieldName.ToUpper() == "txtTrinhky".ToUpper())
                    {
                        if (mv_bSetContent)
                        {
                            string NoidungTK =mv_oNguoiKy.mv_NOI_DUNG;
                            NoidungTK = NoidungTK.Replace("&DIADIEM", Utility.GetRtfUnicodeEscapedString(Utility.Laygiatrithamsohethong("DIA_DIEM", "Địa điểm", false)));
                            NoidungTK = NoidungTK.Replace("&NHANVIEN", Utility.GetRtfUnicodeEscapedString(globalVariables.gv_strTenNhanvien));
                            NoidungTK = NoidungTK.Replace("&NGAYIN", Utility.GetRtfUnicodeEscapedString(Utility.FormatDateTimeWithLocation(globalVariables.SysDate, globalVariables.gv_strDiadiem)));
                            NoidungTK = NoidungTK.Replace("&NGUOIIN", Utility.GetRtfUnicodeEscapedString(globalVariables.gv_strTenNhanvien));
                            NoidungTK = NoidungTK.Replace("&NGAY", Strings.Right("0" + NGAY.Day.ToString(), 2)).Replace("&THANG", Strings.Right("0" + NGAY.Month.ToString(), 2)).Replace("&NAM", NGAY.Year.ToString());
                            RptDoc.SetParameterValue(p[i].ParameterFieldName, NoidungTK);
                        }
                        else
                        {
                            RptDoc.SetParameterValue(p[i].ParameterFieldName,"");
                        }
                        break;
                    }

                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("SetTrinhky-->"+ex.Message);
            }
        }
예제 #26
0
        CrystalDecisions.Shared.ParameterField GetTrinhky(CrystalDecisions.Shared.ParameterFields p)
        {
            try
            {

                CrystalDecisions.Shared.ParameterFields p0 = new CrystalDecisions.Shared.ParameterFields();
                for (int i = 0; i <= p.Count - 1; i++)
                {
                    if (Utility.DoTrim( p[i].ParameterFieldName.ToUpper()) == "txtTrinhky".ToUpper())
                    {
                        this.Text = this.Text + " Có TK";
                        return p[i];
                    }

                }
                this.Text = this.Text + "- Không có TK";
                return null;
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("GetTrinhky-->" + ex.Message);
                return null;
            }
        }
예제 #27
0
    //輸出EXCEL檔案
    private void ExportExcel(string strFileName, CrystalDecisions.CrystalReports.Engine.ReportDocument report)
    {
        //CrystalReport to Excel Stream
        strFileName = HttpUtility.UrlEncode(strFileName + ".XLS", System.Text.Encoding.UTF8);
        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);

        //Stream export file  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//excel檔名  
        Response.ContentType = "application/vnd.ms-excel";
        Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
        Response.Flush();
        Response.Close();
    }
예제 #28
0
 //輸出PDF檔案
 private void ExportPDF(string strFileName, CrystalDecisions.CrystalReports.Engine.ReportDocument report)
 {
     //CrystalReport to PDF Stream
     strFileName = HttpUtility.UrlEncode(strFileName + ".PDF", System.Text.Encoding.UTF8);
     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);
     //Stream export file  
     Response.ClearContent();
     Response.ClearHeaders();
     Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//匯出檔名  
     Response.ContentType = "application/pdf";
     Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
     Response.Flush();
     Response.Close();
 }
 protected void crvReporte_ViewZoom(object source, CrystalDecisions.Web.ZoomEventArgs e)
 {
     ObtenerReporte();
 }
 protected void crvReporte_Search(object source, CrystalDecisions.Web.SearchEventArgs e)
 {
     ObtenerReporte();
     crvReporte.PageZoomFactor = 50;
 }