コード例 #1
0
        private void WriteReportDetail(IDetailItem repDetail, int level, int maxLevel, int columnNumber)
        {
            if (!repDetail.IsRoot)
            {
                _report.AddCell(repDetail.Text, columnNumber, level, TextStyle.TableHeaderGreyCenterdBorder);
            }

            if (repDetail.IsColumn)
            {
                _report.MergeRegion(level, level + maxLevel, columnNumber, columnNumber);
                _report.SetColumnWidth(columnNumber, ((ReportColumn)(repDetail)).Width);
            }
            else
            {
                if (!repDetail.IsRoot)
                {
                    _report.MergeRegion(level, level, columnNumber, repDetail.LeafCount + columnNumber - 1);
                }

                int prevLeavCount = 0;
                foreach (IDetailItem child in repDetail.Children)
                {
                    WriteReportDetail(child, level + 1, repDetail.ChildrenCountLevels - 1, columnNumber + prevLeavCount);
                    prevLeavCount += child.LeafCount;
                }
            }
        }
コード例 #2
0
        private void CreateReport(string reportName, IEnumerable <Doc> docs, Doc docTemplate)
        {
            _report.AddEmptyRows(6);

            Row row = _report.GetNextRow();

            _report.AddCell(reportName, 0, row, TextStyle.Header1);
            _report.SetRowHeight(row, 22);

            if (docs == null)
            {
                return;
            }
            var enumerable = docs as Doc[] ?? docs.ToArray();

            if (!enumerable.Any())
            {
                return;
            }

            Row rowHeader   = _report.GetNextRow();
            int columnIndex = 0;

            foreach (AttributeBase attribute in docTemplate.Attributes)
            {
                AttributeBase attribute1 = attribute;

                _report.AddCell(attribute1.AttrDef.Name, columnIndex, rowHeader, TextStyle.TableHeaderGreyCenterdBorder);

                int colWidth = enumerable.SelectMany(d => d.Attributes)
                               .Where(a => a.AttrDef.Id == attribute1.AttrDef.Id && a.ObjectValue != null)
                               .Select(aa => aa.ObjectValue.ToString().Length).Max();

                _report.SetColumnWidth(columnIndex, colWidth);

                columnIndex++;
            }

            foreach (Doc doc in enumerable)
            {
                var tableRow = _report.GetNextRow();

                var colIndex = 0;
                foreach (var attr in docTemplate.Attributes)
                {
                    var attr1         = attr;
                    var findAttrQuery = (from a in doc.Attributes
                                         where a.AttrDef.Id == attr1.AttrDef.Id
                                         select a).ToList();

                    if (findAttrQuery.Any())
                    {
                        var findedAttr = findAttrQuery.First();
                        if (findedAttr is EnumAttribute)
                        {
                            var enumAttribute = findedAttr as EnumAttribute;
                            if (enumAttribute.Value.HasValue)
                            {
                                string enumValue = _enumRepository.GetEnumValue(enumAttribute.AttrDef.EnumDefType.Id,
                                                                                enumAttribute.Value.Value);
                                _report.AddCell(enumValue, colIndex, tableRow, TextStyle.NormalText);
                            }
                        }
                        else
                        {
                            _report.AddCell(findedAttr.ObjectValue, colIndex, tableRow, TextStyle.NormalText);
                        }
                    }
                    colIndex++;
                }
            }

            _report.AddLogo(0, 0);
        }