123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Data;
- using System.Data.OleDb;
- using CustomControls.Design;
- using DevExpress.XtraReports.UI;
- namespace PatternDemo
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- DataTable rs = new DataTable();
- using (var odConnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\Users\wangbc\Desktop\test.xlsx;Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';"))
- {
- odConnection.Open();
- using (OleDbCommand cmd = new OleDbCommand())
- {
- cmd.Connection = odConnection;
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = "SELECT * FROM [Sheet1$]";
- using (OleDbDataAdapter oleda = new OleDbDataAdapter(cmd))
- {
- oleda.Fill(rs);
- }
- }
- odConnection.Close();
- }
- var report = new XtraReport();
- report.DataSource = rs;
-
- /* 测试循环获取控件 */
- //report.AfterPrint += (sender, args) =>
- //{
- // XtraReport xtraReport = (XtraReport)sender;
- // var a = xtraReport.Pages[0];
- // NestedBrickIterator iterator = new NestedBrickIterator(a.InnerBricks);
- // while (iterator.MoveNext())
- // {
- // VisualBrick visualBrick = iterator.CurrentBrick as VisualBrick;
- // if (visualBrick is TableBrick tableBrick)
- // {
- // var b = tableBrick.Bricks;
- // }
- // }
- //};
- ReportDesignTool designTool = new ReportDesignTool(report);
- CustomControlToolBoxRegistrator.AddPatternControlToToolBox(designTool.DesignRibbonForm.DesignMdiController);
- designTool.ShowRibbonDesignerDialog();
- }
- }
- }
|