Hi there,
My app calls for printing the UG plus the data (parameters) that createt it.
How can I add the data in the report? I mean, "labels" textboxes"...or something like that!
Or the only way is to use Crystal Reports then exporting the UG to it?
If so, how can I export the UG to CR?
Thanks in advance!
I'm not familiar with Crystal Reports, so I can't really say if it is or isn't possible to export the grid to it, but I'm fairly certain that this is not a supported scenario. You can print the grid directly, though, through the UltraGridPrintDocument. You also have the options of exporting it to Excel using the UltraGridExcelExporter, or into a PDF using the UltraGridDocumentExporter and the Documents engine. I think that the NetAdvantage SDK/Samples include demonstrations of how to do this, but if all you want to do is use the exporters, there is an Export method on each.
-Matt
Matt,
Thanks for the answer. I've gone through the SDK examples and this forum a lot of time before making this post.
Honestly I do not want to use Crystal, but I need to print in the same report both the parameter's data plus the grid's data.
I did not found so far any example of how can I "export" other data into a report but the grid's
Any ideas? Can the Report engine be used for what I want?
If so, can you give a little example?
Thanks!
The only case that I am familiar with where you can add other data in addition to the grid is to use the Documents engine and the exporter. Looking at the Documents sample is your best bet for figuring out how to add what you need, but in terms of exporting the grid, you would want to pass in the Report or ISection of the report that you're generating so that the exporter adds the grid to it instead of creating a new one.
The code would be something like:
Report report = new Report();
ISection section = report.AddSection();
// Add content to section
this.ultraGridDocumentExporter1.Export(this.ultraGrid1, section);
// Alternatively, put the grid in its own section
// this.ultraGridDocumentExporter1.Export(this.ultraGrid1, report);
Thanks for the answer, I've done exactly that and while it works, I still have a couple of questions that I hope you can help me on.
1) Once the report is created, the grid, as expected, goes after the section. Problem is, it does not use the same page settings (appears in the PDF as with a different size, orientation and alignment) and that's quite ugly.
How can I solve that? I mean to have a coherent report, where the grid follows the same page's preferences as the section?
2) Is there a way to print the grid's caption?
Thanks a lot in advance !
Gus
If you want to format the grid itself for the report, you can use the InitializeLayout event and check e.Layout.IsExportLayout. I'm honestly not sure if or how you can control the margins around the grid when it's exported, though, aside from the properties directly on the section (i.e. PageMargins, etc). I'm not sure why it would be displaying on the right either, but you might want to play around with some of the properties on the exporter like AutoSize, Margins, TargetPaperOrientation, and TargetPaperSize.
As for the grid text/caption, I'm still not sure where you want it displayed; if you want it in the grid itself, you could show it during the InitializeLayout, as I mentioned above.
Again thanks for the tip. Worked!
But...while now the grid is in the same page (it's part of the section) and that's great, I'll like it to use the same margin and centering options.
I mean, the grid is now displayed on the right, and honestly I don't know of a way to make it centered and using as much width as possible.
Since the only reference I can make to the grid is in the DocumentExporter, then how can I format it beforehand?
Sorry, I meand grid.text not caption!
I think that the grid needs to resize the page sections to fit its contents; you could certainly create your own ISection object and pass that off to the grid, modifying the size of it yourself after the grid has worked with it. As for printing the grid's caption, I'm not sure what you mean. If the caption is visible, you should see it when you export the grid. If you want it as a header to the section, you'd have to add it yourself (using the method I mentioned about regarding creating your own section).