I'm part of a development team that uses JasperReports in our Java application to generate .pdf or .xls reports. Currently we are trying to extend our .xls reports with predefined print settings and macros.
I discovered the report property net.sf.jasperreports.export.xls.workbook.template, whose description seems like a perfect match for this requirement. In our case, the problem now seems to be, that this property cannot be set based on an expression or input parameter (or am I doing it wrong?).
Our server-side architecture (Java) is designed like this: we have a generic JasperReportController, that handles the preparation and exporting of every .jasper/.jrxml file. Reports are populated with default properties and parameters, which the reports designers can use in their reports. Some reports already have dynamic header images, based on language and customer. This was easily implemented with the powerful expression capabilities of JasperReports. But this doesn't seem to be possible with (global) report properties.
What we need:
A report designer should be able to define a workbook template per report: this one is simple, just define the previously mentioned property on the report
The specified template should be dynamic, preferably based on an expression (custom function) like: xlsTemplate('my-template.xls', $P{customer}, $P{language}) -> I have no idea how to do this at the moment
This leads to my question: is there a way to specify a report's property as an expression or is there an other approach to solve my requirements?
The solution should be generic, so that a report designer can define the dynamic .xls template just in the .jrxml file and doesn't need to modify Java code.
Try this, before you fill your report:
String thePath = "... get it from where you like also the jasper report see property map below...."
JRPropertiesMap properties = jasperReport.getPropertiesMap();
properties.put(XlsExporterConfiguration.PROPERTY_WORKBOOK_TEMPLATE,thePath);
Conclusion you edit your generic JasperController, check if there is a certain property in the report,request url, report name of what ever you prefeer, then in base of your logic set the PROPERTY_WORKBOOK_TEMPLATE to the selected template, then fillout the report.
Related
I am fairly new to the Alteryx.
I would like to create a process/workflow in Alteryx to import a file from a specified location but that should be controlled by the input parameters.
Kindly help me in this.
Thanks,
RTJ
You can connect an Interface Tool:File Browse via an Interface Tool:Action to change the file selected to an In/Out:Input Data:
You will then want to run the workflow using the Run As Analytic App:
In the developer tool category, you'll find the Dynamic Input tool. This works much like the standard Input Data tool, but can take records in to modify the data it collects.
https://help.alteryx.com/2018.2/DynamicInput.htm
It sounds like you have files in a standard location, but want to be able to dynamically select the ones to load.
Let's say you have a collection of sales files in the format "Sales_20190718.csv" but want to only get sales information for certain dates as specified in your workflow. You can point your Dynamic Input tool to the Sales_20190718.csv, and have it replace the "20190718" part with whatever input you gave to the tool before querying the information.
You could get a similar result by using wildcards in a basic Input Data tool by pulling data from "Sales_*", and ticking the "Output File Name as Field" box. This would load all your sales data (which could take some time) but then you could filter to the relevant files using the new FileName field.
In COGNOS is there a way to get the definitions (filters, selected fields) from a number of reports in a folder?
I've inherited around 500 reports defined in a folder and they all need to be checked and fixed as they have business errors (not technical errors). If it was possible to get all their definitions in a single extract that would save an enormous amount of time having to click multiple times to get that information from each report one by one.
In ACCESS this can be done with VBA (for query definitions), but I'm not sure if there is a scripting language that can be used with COGNOS to achieve a similar result.
It sounds like you may want to "validate" each of these 500 reports (effectively equivalent to pressing the "validate" button on each individual report if it was open in the authoring studio).
Validation will ensure that a report specification XML is still syntactically correct, references a package which is still present the content store, references only query items from that package which still exist, generates valid SQL vs. the underlying datasource, etc.
If that's what you're looking for, an easy way to do batch validation for all 500 reports would be to use MotioPI (its a free admin tool for Cognos). Here's a short article which walks you through the process:
http://info.motio.com/Blog/bid/70357/Batch-Validation-of-Cognos-Reports
If you're wanting to retrieve the actual report specification (XML) for each of these 500 objects, then you'd need to write a program which utilizes the Cognos SDK to retrieve the specification XML from each of the 500 report objects. After that, you'd need to add logic which examines each of these 500 XML documents, looking for whatever it is you're looking for.
We solved this by exporting the XML of the reports using a SQL query on the content store.
The output is processed with a Python script to convert XML to table layout in CSV format.
This CSV-file can easely be imported in Excel.
You might want to process the reports XML directly in a SQL query with the xmltable function. In our situation this turned out to be a heavy proces we don't want to burden the content store database with. For a small set of reports this is working fine though.
I have reports which I'd like to render to excel using just a link. In order to do this, I have a page (web application, actually) which uses the ReportViewer to select the parameters and then intercepts the rendering phase. I then execute the rendering as an excel render using byte[] result = ReportViewer.ServerReport.Render("Excel"); and sending this to the user.
I got it working, but there's a quirk: The excel files are generated with the headers still in place. The reports define these to not to be rendered when rendering to excel, as the tab names already contain the names and they interfere with one click pivoting.
I've looked through the interface of the reportviewer form, but I can't seen to be able to find anything which would trigger the conditional formatting. Can anyone help me with this?
Make sure the expression in your conditional formatting refers to "EXCELOPENXML" rather than "EXCEL" if you are exporting to .xlsx format. Or you may need to pass this value to the Render function. Or both. If you are exporting to a version of Excel earlier than 2007, this will not apply.
These two format types differ in how they are encoded. My understanding is that an SSRS report rendered as type 'EXCEL' is encoded in binary, whereas those of type 'EXCELOPENXML' are, naturally, encoded in XML.
This is purely speculation, but the visibility expression may expect a specific type of encoding based on the version of Excel you are using. So even though either might render to the application, only one evaluates the expression as you expect.
Problem - Generate a word document from information retrieved from database.
My solution - Create a word document template add fields/tags in places where values need to be inserted. The template will require tables and charts as well. Using document reflector that comes with open office xml sdk reflect on the document template and extract the w:document section and port it to C#. The rest of the logic revolves simply around finding the fields/tags, replacing them, etc. Very simple approach but not very flexible!
Challenge - I want the user to have the ability to customize the template or the generated document output. But this will not be possible if I embed the template logic in code.
Any other possibilities - I looked around at Templating using T4 and RazorEngine but could not find any concrete examples of how to create word documents using these two technologies.
Now what is the best approach?
I would really appreciate your inputs on what is the best and most flexible way to generate word documents using C#.
I'm actually working a project where the business users are designing word template with mail merge fields and we are populating the values using a 3rd party software package Aspose Words. http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx
The software includes a library for merging data from datatables into the mail merge fields in the word document.
I also wrote a customized word task pane add in that retrieves data views from the database and lists the fields in a drag/drop interface that mimics a crystal or sql report writing interface.
Probably would of been easier to just use crystal or sql reporting though...
It's certainly possible to generate the contents of an Office doc using T4 or Razor and then package it up. The TestScribe powertool for Visual Studio Test Manager does just that with T4. There is a thread by Sally Cavanagh in the Q&A on this page http://visualstudiogallery.msdn.microsoft.com/e79e4a0f-f670-47c2-9b8a-3b6f664bf4ae that suggests a way to look at the T4 templates that it uses, which might get you jump-started.
Here is sample to play word document template with C#
You could use a content control databinding approach.
XML Mapping Task Pane for Word 2007/2010 is an authoring tool.
To create an instance document, you just attach your XML data file.
If the resulting documents will be opened in Word, that is all that is required: Word will bind the data itself. If your consuming application is not Word, you might want to resolve the bindings yourself (eg via Open XML SDK).
Content control databinding isn't intended to support repeats and conditionals. For a way to do that, look at my OpenDoPE convention
Take a look at Templater. Disclamer: I'm the author.
Check out JODReports or Docmosis. They are Java based but some of the templating features and output options might be ideal. You can call the command line interfaces unless they also have something better to reach from C#.
I have a List<MyDto> which I want to export with PrimeFaces. I tried with <p:dataExporter>, but it seems that it only uses UI <p:dataTable> content.
How can I directly export a list of DTOs to CSV, Excel or PDF?
You need a library to handle this. Primefaces doesn't inherently know how to display your data (it analyzes the columns and then exports based on that) so you need to give it some hints. The short answer is that you can easily create a table either programatically via reflection on the DTO and binding it to the page or by creating a simple data-table and set it to a style of "display:none" and then using the exporter.
Alternatively you can look at a reporting suite like JasperReports that handles "printing" to the above formats, but again, you will need to do something to interpret it. If you don't care about performance JSON-Lib has a very nice "toXML" method that will rip down a DTO to xml which could then be easily exported to any of the formats you choose.
Basically, you're looking at ~ 1 hour of work if it is a complex set of DTOs or 10 minutes if it isn't--as long as bandwidth isn't an issue this should be completely painless.