Crystal Report Java SDK: How to set export option on columns to 'can grow' when exporting to Excel? - crystal-reports

The title of the question pretty much tells it all.
When using the java SDK provided by Crystal Reports to export a report as an Excel spread-sheet. Although the cells grow even now, only the first line is visible in the export XLS.
In the Crystal Reports UI, this is achieved by setting the 'Grow' option from the Report Export options.
What parameter must be set so that the corresponding cell visibly grows to accomodate large/multi-line text?

Given the hugely different nature of the 2 formats, exporting to Excel is always tricky. However, I did do a quick test exporting a dummy report from my CR standalone developer version, and replicated & solved your problem.
In your text fields that you want grown, go into the Format Editor->Common and turn on the Can Grow option. It looks like this activates Excel's Wrap Lines option, but unforunately also adds extra rows to make up for it.

My problem was that the field width was set to the width of the matter it contained. What worked eventually was to have the field-width in Crystal Report set to slightly smaller than the matter it is to contain.
Say, the matter to be written is 'Address Line One'.
Set the field in design view such that only 'Address' is visible.
Then set the field to 'Can Grow' with 0 (no-limit) on the number of lines to grow.
When the report is exported to XLS, the cell in XLS will be resized to display the rest of the body.

Related

Remove unwanted paragraph space in Jasper Report

I trying a desktop application for a medical laboratory... There are total 5 table in database 1st one consist of the details of patient.... Like...name....age....sex....lab no....doctor refereed by....date Other four table contains the details regarding the test which patient seeks.... Like...blood test.....urine test...etc I'm coming to the point... What I am trying is that if the patient does not undergoes certain test says urine test then none of the details regarding urine test will be printed I have used iText as IDE to generate the report... Everything is working fine except for the fact that some white space (I guess 4 to 5 paragraph changes) is automatically created whenever a report is generated with a skip of a single test type.
How can I resolve the problem?
Screen Shot Of the Report Generated..
Screen Shot of my code :
You are using sub-reports. Are they returning white space even when they are empty? If they are, then the line is never blank.
Look at the "Print When Expression". Can you add a reasonable constraint there? Maybe your main report query can extended to answer which tests have been done - you can then use that info in the "Print When Expression".
It is unusual to put everything into summary band. Put each sub-report in a detail band. With a detail band you have better control over white space between each report. On the detail band you can adjust the "Print When Expression". It will exclude the entire band with white space and all.

jasperreports studio - hard to get the column header to line up with the detail

I have headers/details in the jasper reports studio. everything about this works wonderful minus one annoying thing I have to constantly line up the column headers with the details to make the alignments act correctly... even though i match the alignment exactly in the designer.
This is probably because I have a different font style on Header versus detail... or something? I'm not sure.
I can workaround the issue by manually tweaking X-coords, export the report, make sure they line up, until it looks nice... resulting in a designer like this:
Notice how I moved the values in the Detail 1 band to the left so that the report with actual values lines up the columns correctly.
I must just be doing something wrong right? Why do I have to do this manual tweak to get things to look ok?
I had the same issue when using Jaspersoft Studio.
I'd recommend you to use iReport instead, it's much more convenient for JRXML development and does not have this annoying issue in fields alignment.
It seems that the cells in "Detail 1" are set to display centralized text while the ones in the "Column Header" are left aligned. Try left aligning the text in the Detail 1's cells and see if things work out.

Column visibility not working when exporting to Excel

I have a column in my report that I want to hide based on an expression:
=IIF((ReportItems!Textbox16.Value ="USD" OR Parameters!BinderID.Value=10263 OR Parameters!BinderID.Value=10536 OR Parameters!BinderID.Value=10718 OR Parameters!BinderID.Value=10248 OR Parameters!BinderID.Value=10535 OR Parameters!BinderID.Value=10960),True,False)
When I run the report the hidden expression is working very well: the column is hidden. However, when I export to Excel the column reappears while it shouldn't.
This discussion would suggest it cannot be done, and would require a work around such as a separate report with only the columns wanted.

How to export a crystal report as a fixed character into a text file

I'm trying to export a formula with fixed characters spacing into a text file.
What is happening is that its a long set of fields that is longer then the report page in crystal can show. When running the report it places the additional fields under and it repeats for all the records. When I try to export it to a text file it is pushing it the same way instead of that one record being one whole line across on the text file like I would like it to be. How can this be done. New to crystal thanks in advance.
Since you're exporting to plaintext, I'm assuming you don't care what the format of the actual report is (since it is merely an intermediate player during the export process). If that's the case, then you can just expand the page size horizontally until it can accommodate all of your fields the way you want them.
Your page size is probably 8.5"x11" by default. Go into your Page Setup ("File" -> "Page Setup") and make it the size that suits your fields.
EDIT: If you're using an older version of CR, you may have to use a dummy printer that can accommodate large paper sizes. See here.

Is it possible to show the contents of a text file in Crystal Reports

I have a crystal report which contains a list of absolutely referenced text files. There is one text file referenced in each body line.
e.g.
line1 c:\file1.txt
line2 c:\file2.txt
Is there any way to display the contents of these files in Crystal?
i.e. I would like each crystal body line to show the text from the referenced text file.
I'm using Crystal reports 11 with a non-standard database connector (dataflex).
You would need to set up a file dsn (in XP it's under Control Panel/Administrative Tools/Datasources (ODBC)) and then use the file dsn (Microsoft Text Driver) for the datasource as an ODBC(RDO) connection.
I set this test scenario up on mine like the following:
**File 1**
column1
1row1
1row2
1row3
**File 2**
column1
2row1
2row2
2row3
I set up the file dsn to point to the c drive and in the datasource screen I added file1.txt and file2.txt to the selected tables. Then the easiest thing to do is clear the links of the tables so that it pulls every row. It will warn you that there are multiple starting points. I don't generally recomend this, but it will work in this case and since it's not reporting off a database it probably isn't the end of the world. If you disregard the starting point message then add the fields to the report, when you run it you should get the following output:
1row1 2row1
1row1 2row2
1row1 2row3
1row2 2row1
1row2 2row2
1row2 2row3
1row3 2row1
1row3 2row2
1row3 2row3
From this you can change your grouping to get the output that you need.
You can also use this same connect against subreports instead of doing this linking where you have the main report pull the info from file1.txt and then put a subreport in the report footer that pulls from file2.txt. This option won't have the text collated, but you'd still have it in the same report.
Hope this helps some.
It's easier than you think. I just set up one myself before I wrote this to make sure I was giving you the right steps. Using CR version XI and a .txt file, I followed these steps:
For each text file you want to import, make a subsection in your report (i.e. DetailsA, DetailsB, etc.). If your list of text files is constantly changing (and I don't think it is, based on your description), you'll need another method.
Make sure your text file is comma delimited and the first row contains field names. If these text files are actually text (i.e. not tables), then just put a dummy variable name in the first row so Crystal will see the text as a table of data with just 1 row.
For each text file you want to display, create a new Subreport (Insert->Subreport)
In the database selection menu, go to "Create New Connection"->"Access/Excel (DAO)"
Under 'database type', you'll see a 'text' option at the bottom of the screen.
Choose your file.
Relax! (I'm in a good mood this morning, don't know why)
I guess if you have a function that takes a file name as an argument and returns the contents of that file - you could use that function in a Crystal Report formula.
I am not familiar with the current CR, it has been years since I last used it (I last used version 8). In the versions I did use, such a function was not built in. What you would have to do back then, was to create a UFL (user function library) containing the functions you needed. If I remember correctly, you had to do this using COM.
In this day and age, I guess you can extend CR using some other mechanism, perhaps writing .NET code?
I suggest you search the CR documentation for the term UFL.
Another suggestion, then:
Create a new table FILECONTENTS (filename varchar primary key, contents blob)
Create a script that on a schedule populates this table with the filenames and contents of all the files (assuming that there is a finite number of files, and that you have a way of knowing about them)
Modify the report datasource query to join it with the FILECONTENTS table, and add the contents field to the report.
You could setup a file dsn. But this is geared toward tabular file data, not text.
How big are these text files? You want to display the entire contents of each file?
There is probably no easy way to dynamically read in a file from within crystal. You will most likely have to push a dataset to the report which contains the file contents.