示例#1
0
        /// <summary>
        /// Build report for DataGridView content.
        /// Call this method if you have already set all required parameters.
        /// </summary>
        /// <returns>Report</returns>
        public ReportBase GenerateReport()
        {
            _report = new ReportBase();

            Columns     = reportDataAdapter.GetColumns();
            TableGroups = reportDataAdapter.GetTableGroups(Columns);

            CreateHeaders();
            CopyRowData();

            reportBuilder.AddDataSource(_report.ExportedTable);
            reportBuilder.AddReportTable(_report.ExportedTable, Columns, TableGroups, reportDataAdapter.GetRowHeight());
            reportBuilder.AddEmbeddedImages(_report.GlobalEmbeddedImages);

            string GeneratedRDLC = reportBuilder.BuildRDLC();

            _report.Rdlc = GeneratedRDLC;

#if DEBUG
            DateTime currentTime  = DateTime.Now;
            string   strTime      = string.Format("{0}-{1}_{2}-{3}-{4}", currentTime.Day, currentTime.Month, currentTime.Hour, currentTime.Minute, currentTime.Second);
            string   tempFileName = Path.Combine(
                Path.GetTempPath(),
                string.Format("testReportExport{0}.rdlc", strTime));
            File.WriteAllText(tempFileName, GeneratedRDLC, Encoding.Unicode);
#endif

            return(_report);
        }