private void ResolveReport(Report report, Hashtable parameters) { try { SheetView sheetView = (SheetView)Serializer.LoadObjectXml(typeof(SheetView), Serializer.GetObjectXml(report.ReportSheet, "SheetView"), "SheetView"); ReportEngine reportEngine = new ReportEngine(report.Configuration.DataSources, sheetView, parameters); PageReport pageReport = reportEngine.execute(); PaginateReportIterator iterator = pageReport.generateReportPageIterator(); DynamicValueList ColumnWidthList = ReportHelper.getColumnWidthList(pageReport.ToWorkSheet()); DynamicValueList RowHeightList = ReportHelper.getRowHeightList(pageReport.ToWorkSheet()); DrawingOP drawingOP = new DrawingOP(this, pageReport, RowHeightList, ColumnWidthList); while (iterator.hasNext()) { ReportPage reportPage = iterator.next() as ReportPage; drawingOP.DrawReport(reportPage); } } catch (Exception ex) { Report.Reset(); Report.ColumnCount = 6; Report.RowCount = 2; Report.RowHeaderVisible = false; Report.ColumnHeaderVisible = false; Report.Columns[0].Width = 700; Report.Rows[0].Height = 500; Report.Cells[0, 0].Text = "报表解析出错:" + ex.Message; } }
public PaginateReportIterator(PageReport paramPageReport) { this.showReport = paramPageReport; this.reportSettings = this.showReport.getReportSettings(); this.columnWidthList = ReportHelper.getColumnWidthList(paramPageReport.ToWorkSheet()); this.rowHeightList = ReportHelper.getRowHeightList(paramPageReport.ToWorkSheet()); dealWithPageInfor(); }
protected void DoPageInfo() { SheetView source_report = reportPanel.Report; FpSpread source_fpspread = reportPanel.ReportSpread; source_report.PrintInfo.CopyFrom(pageReport.getReportSettings()); source_report.Rows.Count = 0; source_report.Columns.Count = 0; Dictionary <int, int> pageRowIndexs = new Dictionary <int, int>(); Dictionary <int, int> pageColumnIndexs = new Dictionary <int, int>(); while (iterator.hasNext()) { ReportPage reportPage = iterator.next() as ReportPage; float[] columns = reportPage.getColumnWidthArray(); float[] rows = reportPage.getRowHeightArray(); if (!pageColumnIndexs.ContainsKey(reportPage.getPageColumnIndex())) { pageColumnIndexs.Add(reportPage.getPageColumnIndex(), source_report.Columns.Count); source_report.Columns.Add(source_report.Columns.Count, columns.Length); for (int i = columns.Length - 1; i >= 0; i--) { source_report.Columns[source_report.Columns.Count - 1 - i].Width = columns[columns.Length - 1 - i]; } source_report.Columns[pageColumnIndexs[reportPage.getPageColumnIndex()]].PageBreak = true; } if (!pageRowIndexs.ContainsKey(reportPage.getPageRowIndex())) { pageRowIndexs.Add(reportPage.getPageRowIndex(), source_report.Rows.Count); source_report.Rows.Add(source_report.Rows.Count, rows.Length); for (int i = rows.Length - 1; i >= 0; i--) { source_report.Rows[source_report.Rows.Count - 1 - i].Height = rows[rows.Length - 1 - i]; } source_report.Rows[pageRowIndexs[reportPage.getPageRowIndex()]].PageBreak = true; } Rectangle Rect = new Rectangle(); Rect.X = pageRowIndexs[reportPage.getPageRowIndex()]; Rect.Y = pageColumnIndexs[reportPage.getPageColumnIndex()]; Rect.Width = rows.Length; Rect.Height = columns.Length; PageRectangles[reportPage.getPageRowIndex() - 1, reportPage.getPageColumnIndex() - 1] = Rect; } int FloatColumnCount = 0, FloatRowCount = 0; foreach (IElement Shape in pageReport.ToWorkSheet().DrawingContainer.ContainedObjects) { if (Shape is FloatElement) { FloatElement localFloatElement = Shape as FloatElement; Point[] arrayOfPoint = ReportHelper.calculateLastColumnAndRowOfFloatElement(pageReport.ToWorkSheet(), localFloatElement); FloatColumnCount = Math.Max(FloatColumnCount, arrayOfPoint[0].X); FloatRowCount = Math.Max(FloatRowCount, arrayOfPoint[0].Y); } } if (source_report.Columns.Count < FloatColumnCount) { source_report.Columns.Add(source_report.Columns.Count, FloatColumnCount - source_report.Columns.Count); } if (source_report.Rows.Count < FloatRowCount) { source_report.Rows.Add(source_report.Rows.Count, FloatRowCount - source_report.Rows.Count); } foreach (IElement Shape in pageReport.ToWorkSheet().DrawingContainer.ContainedObjects) { if (Shape is FloatElement) { FloatElement localFloatElement = Shape as FloatElement; FloatElement tmpfloatElement = localFloatElement.Clone() as FloatElement; tmpfloatElement.Locked = true; source_report.AddShape(tmpfloatElement); tmpfloatElement.Update(); } } }