I am using Jasper Report API 4.5 (ready to update if required for this solution). With Jasper Report I am exporting report to HTML, Excel, CSV and PDF. A situation I came across is that if data is having valid excel formula then on exporting data to Excel and CSV and viewing file to MS Excel, it executes excel formula. This causes a security issue as some data is having excel formula to perform some action on local computer then it may harm system.
We can not validate data at the time of insertion, doing so may fix the problem. But currently there is no data validation as such to prevent inserting excel formula. Preferred solution to me is to manage from Jasper Report.
My question is, is there any mechanism or export parameter which can prevent excel formula to be executed? Or is there any way to print data as is and ignore excel formula?
For Excel export:
We can use Apache POI or SmartXLS API to set cell type to Text externally in order to get same result from database.
For Apache POI, we can set cell format type as "#", here is the link from Apache POI javadoc.
For SmartXLS, we can set workbook range style to set format type as Text, code snippet for it would be like below:
RangeStyle rangeStyle = workBook.getRangeStyle(1, 0, 50, 0);
rangeStyle.setCustomFormat("#");
For CSV Export:
Upgraded JasperReport 6.3. There is a feature to add enclosure to csv field. By default excel have single quote (') as field enclosure, so that may execute the field as formula. To avoid that we can set enclosure field to (`).
SimpleCsvExporterConfiguration reportExportConf = new SimpleCsvExporterConfiguration();
reportExportConf.setFieldEnclosure("`");
reportExportConf.setForceFieldEnclosure(true);
Related
Within our database we have invoices being saved and uploaded as a PDF; however within Crystal Report the field is marked as a blob. When attempting to drag this field onto the report it comes out blank, is there a way to have the image appear on CR XI, from a blob field?
I am using Crystal Report 11.5.11.1470
I am using a SQL Database, Syntax is SQLServer
Based on my research, and experience, you cannot display a blobulized PDF in a Crystal report.
https://scn.sap.com/thread/3207588
Please note that Crystal Reports does not support anything other than 'Images' in Blob fields. If that Blob field has text, pdf file, doc file or just anything other than an image, Crystal Reports will return Blank.
There is a false statement floating around that you can add an OLE PDF object to Crystal and then change the location of the PDF to reflect the Blobulized field, but this does not work - a blob field cannot be used in a formula.
One option would be to use another program/utility to retrieve the PDF from the blob, run the Crystal Report and export to PDF, then combine both of the files. Depending on the report and the blob, that may not work.
Otherwise, you could possibly convert the blob to another data type and then use Crystal to display the data.
I have a crystal report where I need to mail the users the data in the excel as an attachment but with the condition that filters are enabled in each columns of the excel report .
If I have 10 columns in excel , user doesn't want to apply filter explicitly rather they want the filter already present so that they can filter based on any column .
If there is another better way of filtering the data on user side please suggest that too.
There is no way to do this from within Crystal reports. You can write an application, which will export the report to Excel, open the Excel file and add a filter.
There is a free version of R-Tag, which supports this feature. You can see it demonstrated here: http://www.r-tag.com/Pages/Preview_RTagAndBOE.aspx
Use the menu to jump to "Advanced report extensions" or go to position 5:26
If this works for you, here is the link to the free edition:
http://www.r-tag.com/Pages/CommunityEdition.aspx
From 2008 Crystal Report view, the number format reads as 580015704027 in which is correct.
When exporting data from .rpt to .csv, that number format changes to 5.80016E+11.
How do I make it stick so that it will be exported correctly while on automation?
Thank you,
Holly
Here is the solution.
This solution works if you are using a database field with number format.
Right click on the filed go to Format Field.
Move to tab Number.
select last option (1,123.0000)
Now export to .CSV format.
I've produced a report in Crystal Reports XI where I in one of the fields have used the display string formula to alter the apperance of some data as well as group similar data values to one value (e.g. "neg", "negative", and "-" now all displays as "negative" in the report.)
However, now when I export the report to CSV for delivery to a customer the raw data, and not the display string formula result, is in the export. I've tried all 4 settings with the checkboxes in the CSV export options.
Is there any way to make the display string formatted data beeing exported to the CSV?
Are there any alternate ways of achiving the desired formatting and getting the formatting preserved in CSV export?
Unfortunately, i've not found a way of using the display string formula and achieving the desired result.
Instead create a new formula and replace the object on the report with the new formula.
L
I have 20 reports where the header and footer are not at all aligned. Because of that, while doing a CSV export, the file has lot of empty spaces. Is there an easy way to access the design part of the report programatically instead of changing the layout?.
TU
If you do not want the template formatting to affect the CSV export, you shall use JRCsvMetadataExporter which extracts the data but not the formatting. So there won't be any empty spaces if the field has data. The order in which the columns should be printed in CSV can be fed programmatically.
Also to access the template design programmatically you can use JasperDesign object