private DetailBand CreateRowDetail(ExplainReport p_info) { DetailBand new_Detail = new DetailBand(); new_Detail.Dpi = 254F; if (p_info != null) { XRLabel m_Explain = new XRLabel(); m_Explain.Dpi = 254F; m_Explain.Font = p_info.ExplainFont; m_Explain.Text = p_info.ExplainContent; m_Explain.Multiline = true; m_Explain.Width = this.PageWidth - (this.Margins.Left + this.Margins.Right) - 4; new_Detail.Controls.Add(m_Explain); } return(new_Detail); }
/// <summary> /// 初始化报表 /// </summary> /// <param name="p_info">报表格式对象</param> public GenerateReport(_ObjectReport p_info) { this.ReportUnit = ReportUnit.TenthsOfAMillimeter; //使用0.1毫米计量单位 this.Dpi = 254F; this.Bands.Clear(); if (p_info != null) { switch (p_info.GetType().Name) { case "TableReport": TableReport m_info = p_info as TableReport; this.DataSource = m_info.DataSource; this.Margins = m_info.Margins; this.PaperKind = m_info.PaperKind; this.Landscape = this.IsDirection(m_info.Landscape); DetailBand new_Detail = CreateTableDetail(m_info); PageHeaderBand new_PageHeaderBand = CreateTableHeader(m_info); this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { new_PageHeaderBand, new_Detail }); break; case "PageReport": PageReport m_pinfo = p_info as PageReport; this.Margins = m_pinfo.Margins; this.PaperKind = m_pinfo.PaperKind; this.Landscape = this.IsDirection(m_pinfo.Landscape); DetailBand new_pDetail = this.CreateRowDetail(m_pinfo); this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { new_pDetail }); break; case "ExplainReport": ExplainReport m_ExplainReport = p_info as ExplainReport; this.Margins = m_ExplainReport.Margins; this.PaperKind = m_ExplainReport.PaperKind; this.DataSource = null; this.Landscape = this.IsDirection(m_ExplainReport.Landscape); DetailBand new_EDetail = this.CreateRowDetail(m_ExplainReport); PageHeaderBand new_ExplainPageHeaderBand = CreateTitleHeader(m_ExplainReport); this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { new_ExplainPageHeaderBand, new_EDetail }); break; default: break; } } }
private void ExportExcel(string fileName, ExplainReport reportSource) { }
/// <summary> /// 创建页头 /// </summary> /// <param name="p_info">表格报表对象</param> /// <returns>页头内容</returns> private PageHeaderBand CreateTitleHeader(ExplainReport p_info) { PageHeaderBand new_PageHeaderBand = new PageHeaderBand(); XRTable headerTable = new XRTable(); headerTable.Dpi = 254F; headerTable.Name = "Page"; headerTable.Width = this.PageWidth - (this.Margins.Left + this.Margins.Right) - 4; headerTable.Height = 56; if (p_info.TitleCaption != string.Empty) { XRTableRow titleRow = new XRTableRow(); titleRow.Dpi = 254F; //标题 XRTableCell titleCell = new XRTableCell(); titleCell.Dpi = 254F; titleCell.Text = p_info.TitleCaption; titleCell.TextAlignment = this.Alignments(p_info.TitleTextAlignment); titleCell.Width = this.PageWidth - (this.Margins.Left + this.Margins.Right) - 4; titleCell.Font = p_info.TitleFont; titleCell.BorderWidth = 0; titleRow.Height = (int)MeasureString(p_info.TitleCaption, p_info.TitleFont, titleCell.Width).Height + 1; titleRow.Cells.Add(titleCell); headerTable.Rows.Add(titleRow); } XRTableRow x_titleRow = new XRTableRow(); x_titleRow.Dpi = 254F; x_titleRow.Height = 56; //项目名称 XRTableCell l_titleCell = new XRTableCell(); l_titleCell.Dpi = 254F; l_titleCell.TextAlignment = TextAlignment.MiddleLeft; l_titleCell.Width = (headerTable.Width / 2); l_titleCell.Font = new Font("宋体", 9F); l_titleCell.BorderWidth = 0; x_titleRow.Cells.Add(l_titleCell); //专业名称 XRTableCell r_titleCell = new XRTableCell(); r_titleCell.Dpi = 254F; r_titleCell.Width = (headerTable.Width / 2); r_titleCell.BorderWidth = 0; XRPageInfo m_pageInfo = new XRPageInfo(); m_pageInfo.Dpi = 254F; m_pageInfo.Font = new Font("宋体", 9F); m_pageInfo.TextAlignment = TextAlignment.MiddleRight; m_pageInfo.Width = (headerTable.Width / 2); m_pageInfo.Height = 56; r_titleCell.Controls.Add(m_pageInfo); x_titleRow.Cells.Add(r_titleCell); headerTable.Rows.Add(x_titleRow); XRLine m_ContentLength = new XRLine(); //底线 m_ContentLength.Dpi = 254F; m_ContentLength.Top = headerTable.Height; m_ContentLength.Width = this.PageWidth - (this.Margins.Left + this.Margins.Right) - 4; switch (p_info.ReportType) { case "项目报表": l_titleCell.Text = string.Format("项目名称:{0}", p_info.XMMC); m_pageInfo.Format = "\t第{0}页/共{1}页"; break; case "单位报表": l_titleCell.Text = string.Format("工程名称:{0}", p_info.XMMC); m_pageInfo.Format = string.Format("专业名称:{0}", p_info.ZYMC) + "\t第{0}页/共{1}页"; break; default: break; } new_PageHeaderBand.Controls.Add(headerTable); new_PageHeaderBand.Controls.Add(m_ContentLength); new_PageHeaderBand.HeightF = 0; return(new_PageHeaderBand); }