Interchangeability is the law of nature. Every matter in the universe, from mass to energy, can be transformed from one form to another. The main advantage of interchangeability is the flexibility to achieve the requirement harnessing the best use of any form. Nevertheless, its true for various aspects in IT as well.
ComponentOne Studio Reports for WinForms provides various components to meet one's reporting, printing, previewing and exporting needs. C1Reports come with two reporting flavors- C1Report and C1PrintDocument, each with its own specific specialty which can be harnessed depending on the user-scenarios. On one hand, C1Report component is a typical reporting control which exposes a rich object model for creating, customizing, loading and saving data-based banded reports. On the other hand, the C1PrintDocument component provides a rich object model allowing to create non-reflowable documents at runtime. For more information on preference and usage of these two components, take a look at the article: From the Realm of Reports and Documents: Preference and Usage. As humans, we need optimized solutions to make the best use of each and every resource. It would be really great if one could use a few features of C1Report with other extensions of C1PrintDocument in order to enhance the usability.
First thing first, in order to import C1Report into the C1PrintDocument object, we can use the ImportC1Report method of C1PrintDocument. This imports a C1Report definition into the current document and enables us to extend the functionalities on the document level itself.
C1PrintDocument1.ImportC1Report("../../SampleReport.xml", "Sample Report")
After a C1Report has been imported into C1PrintDocument, the document has the following structure:
Each section of C1Report can be represented by 'RenderSection' object. For eg. The page footer is represented by a RenderSection object and is assigned to the document's PageLayouts.Default.PageFooter property.
For each group, a RenderArea is created, and the following object tree is placed between the PageHeader and Footer sections (for two groups):
Now, we can easily modify/add fields in C1PrintDocument using 'RenderField' object.
There are a number of functionalities exclusively provided by C1PrintDocument. They can be added to the document after a C1Report has been imported in C1PrintDocument.
Dim rf1 As New RenderField()
Dim headerSection As RenderSection = C1PrintDocument1.Body.Children("Header")
rf1 = headerSection.Children("titleLbl")
rf1.Style.Shadow.Color = Color.LightGreen
rf1.Style.Shadow.Transparency = 70
rf1.Style.Padding.Right = New Unit("1cm")
rf1.Style.CharSpacing = New Unit("2mm")
rf1.Style.Borders.Left = New LineDef(New Unit("3mm"), Color.AliceBlue)
Dim linkTarget = New C1.C1Preview.C1LinkTargetPage(C1.C1Preview.PageJumpTypeEnum.Last)
Dim rf2 As New RenderField()
rf2 = headerSection.Children("Field4")
Dim hyper As New C1Hyperlink()
hyper.LinkTarget = linkTarget
rf2.Hyperlink = hyper
You can do a lot more than just modifying the styling. Have fun!