Aligning the data while doing a CSV Export in jasperreports - jasper-reports

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

Related

Crystal Reports: how do i export a table to excel data and insert line breaks without getting everything on one horizontal line?

i'm new to CR. i have a report basically consisting of 2 tables of data(data comes from several subreports, not crosstab) and whenever i export to excel data it all comes out under 1 line, the entire report.
i've tried adding adding Chr(10)/Chr(13)/Chrw(10)/Chrw(13) at the beginning of each line, together with the data as well as a separated formula but only get an empty cell, instead of a new line.
if i separate the data in different sections, i'd lose the "table" look as i cannot extend lines&boxes over the section length.
i'm out of ideas at this point. anybody?
Option 1: get the data into a single data set. For example, use a Command/View/SP with a UNION ALL in the SQL.
Option 2: at least one of the 3rd-party Crystal Reports tools listed here allows you to automate the process of exporting one report to Excel and append the Excel export of a 2nd report to the same Excel workbook and worksheet.

Crystal Reports – Extra columns when exporting (Microsoft Excel (97-2003) format only)

When exporting a Crystal Report (2016) to excel format, I am getting extra columns in the report. This does not happen with any other export format. So empty data columns display in the first 30+ columns. How can I correct that?
This can get frustrating if the report is too complex, but if you design the report so that no fields overlap and there are no gaps between the fields, then the export should work better. However, if you have fields and objects in sections where the widths of things in one section differ from the width of things in another section, then you are going to get merged cells and empty cells in your export.
Sometimes its much easier to export the report using one of the (Data Only) Excel export options. This can help to force the export into single cells without merges and gaps, however, the exported spreadsheet will be unformatted and will require some manual formatting after the export when using this method.

Jasper Report Excel-CSV Export: Prevent executing excel formula

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);

Issue in Exporting SSRS Reports to CSV

I have an SSRS Report in which few columns will be made visible programmatically. The Report gets generated succesfully, but when it's exported to CSV, the columns whose "visible" attribute has been handled programmatically doesn't get exproted to CSV.
Is there a work-around for this
issue?
What is the best way to implement
hide logic for columns in SSRS so
that there are no issues while
exproting to CSV/Excel?
See http://blogs.msdn.com/b/bimusings/archive/2007/02/07/reporting-services-why-aren-t-all-my-report-columns-exporting-to-csv-and-or-xml.aspx which explains that CSV (and XML) is a data format rather than a layout format. If the visibility is toggled via a formula as you're doing, it won't be rendered at all in CSV (even if the visibility setting makes it visible).

How to create Excel document with proper cell alignment using Ireport?

I can able to create Excel document using Jasper Report but the problem is that fields are not properly aligned in the cells of excel sheet and all the data are populated in the plain surface without any cells.i.e) I cannot see any cells in the data populated area.Can u please give me suggestion to make proper Excel document with cell alignment.
I had this same struggle and came up with the following. At the time, I was using iReport (3.0.0) and was able to generate a good xls file. It may be easier in newer versions of iReport and/or JasperReports. Here's what I did:
I created a new report using the new report wizard and chose a tabular template. This creates a report with all of the fields in a line with no gaps between them. It is very key that fields are vertically aligned, that all the same height, and that there are no gaps between fields.
I removed all of the extra objects created (title, extra lines) except for the fields and the headers. I then collapsed all of the bands except the column header and detail bands.
On the report properties, I checked "Ignore pagination"
I changed the text color of the header fields, otherwise it ends up as white on white.
The rest of the important options can be found by selecting Options -> Export Options from the menu and then scrolling down to the "XLS Exporter" section. I attached a screen shot of the options I chose. You can experiment with the settings, but I found (through trial and error) that the options I ended up with work pretty well. These options are not stored in the report def file, they are attributes of the thing generating the report. iReport takes care of it when testing in that environment. We are using custom Java to generate the report in production and we set the attributes there.
XLS Exporter Dialog http://www.imagechicken.com/uploads/1270760205041768200.png