cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need help setting export options

Former Member
0 Likes
426

I'm working on replacing our old RDC component with the new Java SDK.

I purchased Crystal Reports 2008 and downloaded the SDK. Now I'm trying to run a simple example exporting a report to word. I've built it off of the other export examples I've seen on the site. None of them seem to give me an up to date example of how to set export options though.

Exporting seems to work when I export using this:

ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) report.getPrintOutputController().export(ReportExportFormat.MSWord);

But not when I do this:

ExportOptions opt = new ExportOptions();

opt.setExportFormatType(ReportExportFormat.MSWord);

RTFWordExportFormatOptions myOptions = new RTFWordExportFormatOptions();

opt.setFormatOptions(myOptions);

ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) report.getPrintOutputController().export(opt);

Is there something I'm missing? I want to be able to explicitly set my export options - especially for other export formats like excel.

View Entire Topic
ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

Try retrieving and modifying the saved export options, rather than constructing your own.

Here's an example for CSV:

Sincerely,

Ted Ueda

Former Member
0 Likes

Unfortunately I must still be doing something wrong. The csv is exported but it comes back with gibberish characters in the file instead of what is in my Crystal. PDF comes back fine but the other export formats (xls, doc, csv, etc.) all come back with gibberish characters.

Here is an example of the csv export code I'm using::

ExportOptions opt = new ExportOptions();

CharacterSeparatedValuesExportFormatOptions csvOptions = new CharacterSeparatedValuesExportFormatOptions();

csvOptions.setSeparator(",");

csvOptions.setDelimiter("\"");

opt.setExportFormatType(ReportExportFormat.characterSeparatedValues);

opt.setFormatOptions(csvOptions);

ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) report.getPrintOutputController().export(opt);

I don't believe I can use ReportExportControl - it doesn't seem to be a part of the SDK I downloaded(but maybe I'm missing something) - I need the SDK version for Crystal Reports 2008.

I do have Microsoft Office 2003. Maybe this is causing issues?

ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

Don't know what gibberish means - are you saying the information has incorrect character encoding?

Sincerely,

Ted Ueda

Former Member
0 Likes

Yes I mean incorrect character encoding.

It looks something like this:

%PDF-1.7

%âãÏÓ

7 0 obj

/<<

/Contents

/Parent 5 0 R

/Resources 6 0 R

/Type /Page

/>>

endobj

6 0 obj

/<<

/Font <<

/ttf0 11 0 R

/ttf1 17 0 R

/>>

/ProcSet 21 0 R

/>>

endobj

8 0 obj

/<<

/Filter

/Length 429

/>>

stream

xu0153mR[ou203A0 ~÷¯8u21224u0153ã NxkÒiÒ¤N]±´gFu0153.Su20ACԁIý÷;6£

idpà|u2014søu0153å½ÿ{¨ýÓ×

ted_ueda
Product and Topic Expert
Product and Topic Expert
0 Likes

So you're exporting to PDF?

Sincerely,

Ted Ueda

Former Member
0 Likes

sigh Never mind....it looks like I was doing something else up in my code that was causing this error to occur.

Thanks for the help.