Exemplo n.º 1
0
        public XpsDocument CreateReport(ReportDefinition rd, ReportData rData)
        {
            //int pageWidth = 700;//just for testing !! get it from your printer
            int          pageWidth = (int)XpsPrintHelper.GetImagebleWidth(); //XpsPrintHelper.GetPageWidth();
            FlowDocument fd        = new FlowDocument();

            fd.Name        = rd.ReportName;
            fd.ColumnWidth = pageWidth;
            fd.Blocks.Add(createReportPart <Section>(rd.HeaderTemplate, rData.ReportGroup));

            TableRowGroup trg = new TableRowGroup();

            for (int i = 0; i < rData.Groups.Count; i++)
            {
                addGroup(rd, trg, rData.Groups[i], rData.Rows);
            }
            MemoryStream tableStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(rd.TableDefinition));
            Table        table       = (Table)XamlReader.Load(tableStream, XamlContext);

            table.RowGroups.Add(trg);
            fd.Blocks.Add(table);

            fd.Blocks.Add(createReportPart <Section>(rd.FooterTemplate, rData.ReportGroup));

            return(ReportPaginator.CreateXpsDocument(fd, rd.Page));
        }
Exemplo n.º 2
0
        public FlowDocument CreateFlowDocumentReport(ReportDefinition rd, ReportData rData)
        {
            int          pageWidth = (int)XpsPrintHelper.GetImagebleWidth(); //700;//just for testing !! get it from your printer
            FlowDocument fd        = new FlowDocument();

            fd.ColumnWidth = pageWidth;
            fd.Blocks.Add(createReportPart <Section>(rd.HeaderTemplate, rData.ReportGroup));
            TableRowGroup trg = new TableRowGroup();

            for (int i = 0; i < rData.Groups.Count; i++)
            {
                addGroup(rd, trg, rData.Groups[i], rData.Rows);
            }
            MemoryStream tableStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(rd.TableDefinition));
            Table        table       = (Table)XamlReader.Load(tableStream, XamlContext);

            table.RowGroups.Add(trg);
            fd.Blocks.Add(table);
            fd.Blocks.Add(createReportPart <Section>(rd.FooterTemplate, rData.ReportGroup));
            //return ReportPaginator.CreateXpsDocument(fd, rd.Page);


            // Open the file that contains the FlowDocument...
            // FileStream xamlFile = new FileStream("../Debug/Data/SalesSummaryReport", FileMode.Open, FileAccess.Read);
            // and parse the file with the XamlReader.Load method.
            // FlowDocument fd = XamlReader.Load(xamlFile) as FlowDocument;
            // xamlFile.Close();

            return(fd);
        }
Exemplo n.º 3
0
 void addGroup(ReportDefinition rd, TableRowGroup trg, GroupData group, DataTable rData)
 {
     copyFromRowGroup(rd.Groups[group.Level].HeaderTemplate, trg, group);
     if (group.HasNestedGroups)
     {
         foreach (GroupData g in group.NestedDataGroups)
         {
             addGroup(rd, trg, g, rData);
         }
     }
     else
     {
         int endRow = group.StartRow + group.Count;
         for (int i = group.StartRow; i < endRow; i++)
         {
             DataRow r = rData.Rows[i];
             trg.Rows.Add(createReportPart <TableRow>(rd.ItemTemplate, r));
         }
     }
     copyFromRowGroup(rd.Groups[group.Level].FooterTemplate, trg, group);
 }