Example #1
0
        //选择打印样式
        private void cboPrintStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboPrintStyle.SelectedItem == null)
            {
                return;
            }
            DataRowView drv = (DataRowView)cboPrintStyle.SelectedItem;
            //样式ID
            string styleID = CommonCtrl.IsNullToString(drv["style_id"]);

            //如果是默认样式,则不用设为默认样式
            btnDefault.Enabled = styleID.Length > 0 && CommonCtrl.IsNullToString(drv["is_default"]) != "1";
            //如果有样式ID,才可以删除
            btnDelete.Enabled = styleID.Length > 0;

            if (dt == null || dt.Rows.Count == 0)
            {
                return;
            }
            string printStyle = CommonCtrl.IsNullToString(cboPrintStyle.SelectedValue);

            FastReport.Report rep;
            //FileTransferOperation fileOperation = new FileTransferOperation();
            ////如果下载出问题,用默认样式
            //if (!fileOperation.DownLoadFile(printStyle, "Report"))
            //{
            //    //LoadDefaultStyle();
            //    reportEx.LoadDefaultStyle(designerReport);
            //}
            //fileOperation.DownFile += new HXCFileTransferCache_Client.DownLoadFileHandler<HXCFileTransferCache_Client.DownLoadFileEventArgs>(fileOperation_DownFile);
            //下载打印样式
            string fileName = FileOperation.DownLoadFileByFile(cboPrintStyle.SelectedValue.ToString(), "Report");

            //如果没找到,则用默认样式
            if (string.IsNullOrEmpty(fileName))
            {
                FastReportEx reportEx = new FastReportEx();
                reportEx.styleObject = styleObject;
                reportEx.dt          = dt;
                reportEx.dicSpanRows = dicSpanRows;
                reportEx.styleTitle  = styleTitle;
                rep = reportEx.DefaultReport();
                if (rep == null)
                {
                    return;
                }
            }
            else
            {
                rep = new FastReport.Report();
                rep.Load(fileName);
                if (dt != null && dt.Rows.Count > 0)
                {
                    rep.RegisterData(dt, styleObject);
                }
            }
            designerReport.Report = rep;
            designerReport.RefreshLayout();
        }
        //选择打印样式
        private void cboPrintStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboPrintStyle.SelectedItem == null)
            {
                return;
            }
            DataRowView drv = (DataRowView)cboPrintStyle.SelectedItem;
            //样式ID
            string styleID = CommonCtrl.IsNullToString(drv["style_id"]);
            //如果是默认样式,则不用设为默认样式
            btnDefault.Enabled = styleID.Length > 0 && CommonCtrl.IsNullToString(drv["is_default"]) != "1";
            //如果有样式ID,才可以删除
            btnDelete.Enabled = styleID.Length > 0;

            if (dt == null || dt.Rows.Count == 0)
            {
                return;
            }
            string printStyle = CommonCtrl.IsNullToString(cboPrintStyle.SelectedValue);
            FastReport.Report rep;
            //FileTransferOperation fileOperation = new FileTransferOperation();
            ////如果下载出问题,用默认样式
            //if (!fileOperation.DownLoadFile(printStyle, "Report"))
            //{
            //    //LoadDefaultStyle();
            //    reportEx.LoadDefaultStyle(designerReport);
            //}
            //fileOperation.DownFile += new HXCFileTransferCache_Client.DownLoadFileHandler<HXCFileTransferCache_Client.DownLoadFileEventArgs>(fileOperation_DownFile);
            //下载打印样式
            string fileName = FileOperation.DownLoadFileByFile(cboPrintStyle.SelectedValue.ToString(), "Report");
            //如果没找到,则用默认样式
            if (string.IsNullOrEmpty(fileName))
            {
                FastReportEx reportEx = new FastReportEx();
                reportEx.styleObject = styleObject;
                reportEx.dt = dt;
                reportEx.dicSpanRows = dicSpanRows;
                reportEx.styleTitle = styleTitle;
                rep = reportEx.DefaultReport();
                if (rep == null)
                {
                    return;
                }
            }
            else
            {
                rep = new FastReport.Report();
                rep.Load(fileName);
                if (dt != null && dt.Rows.Count > 0)
                {
                    rep.RegisterData(dt, styleObject);
                }
            }
            designerReport.Report = rep;
            designerReport.RefreshLayout();
        }
Example #3
0
 /// <summary>
 /// 生成报表
 /// </summary>
 /// <param name="dt">报表数据</param>
 /// <returns></returns>
 public FastReport.Report GetReport(DataTable dt)
 {
     FastReportEx reportEx = new FastReportEx();
     reportEx.styleObject = printObject;
     reportEx.styleTitle = printTitle;
     reportEx.ReportPaperSize = paperSize;
     reportEx.dt = dt;
     return reportEx.DefaultReport();
 }