public static void Print(string title, string timeStr, GridControl gridControl1)
        {
            PrintComponent_XtraForm printView = PrintComponent_XtraForm.CreateReport();
            var ds        = new DataSet();
            var dt        = gridControl1.DataSource as DataTable;
            var gridView1 = gridControl1.MainView as GridView;

            if (dt == null)
            {
                return;
            }
            var dtTemp = dt.Copy();

            foreach (DevExpress.XtraGrid.Columns.GridColumn column in gridView1.Columns)
            {
                if (dtTemp.Columns.Contains(column.FieldName))
                {
                    dtTemp.Columns[column.FieldName].ColumnName = column.Caption;
                }
            }
            if (dtTemp.DataSet == null)
            {
                ds.Tables.Add(dtTemp);
            }
            else
            {
                ds = dtTemp.DataSet;
            }
            var report = new AutoGenerateColumn_XtraReport();

            report.CustomSizeList = new Dictionary <string, float>();
            report.Init(ds);
            printView.Init(report, ds, title, "编制单位:", "报表日期:" + timeStr,
                           "单位名称:", "打印人:", "",
                           String.Format("打印时间: {0:g}", DateTime.Now), true);
            report.PrintingSystem.PageSettings.Landscape = true;
            printView.Show();
        }
예제 #2
0
        //public string Title;
        //public string LeftHeader;
        //public string MiddleHeader;
        //public string RightHeader;
        //public string LeftFooter;
        //public string MiddleFooter;
        //public string RightFooter;

        public static PrintComponent_XtraForm CreateReport()
        {
            var printView = new PrintComponent_XtraForm();

            return(printView);
        }