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

How to use an array (or generated xml string) from splitted string as datasource in subreport

0 Likes
1,207

Hello community,


let's say i have data provided from third party software (that means, I can't influence the content), looking like this:

employee_name, date, courses, information_c1, information_c2, information_c3
"max", "2021-06-15", "c1, c2", "description_c1", "description_c2", "description_c3"
"kai", "2021-06-13", "c2, c3", "description_c1", "description_c2", "description_c3"


The main report contains values like name and date. Now, for each course attended (c1, c2, c3, ...) a subreport should output several information like course name (i.e. c1), a symbol (done with an if condition comparing "if course equals c1 print symbol_1, else if .. print symbol_2....) and the text of the infromation column belonging to the course. These diffent contents will have different font settings (font-family, size, underlinings, ...)

As far as I can see, to do so, it'd be necessary to split the string into an array and provide that array as the datasource for the subreport. But I can't figure out, how to do that. All examples with splitt-calls I could find, just use the splitted values directly in a formula, so the formatting options of subreports can't be used.

Alternativley I would also be happy with a solution to create a xml string using an aray locally in an formula and provide this xml string as datasource. But that ends in a similar issue - I can only find options to use xml data from a file from disk. Is there any option?
For processing a xml file I would have a working solution.

Accepted Solutions (0)

Answers (6)

Answers (6)

ido_millet
Active Contributor
0 Likes

You can simply place the descriptions as lines in a text box and turn on the option to suppress blank lines).

Or place the descriptions in Detail a, Detail b, etc. (and suppress blank sections).

Or create a formula with a global string variable (read online help if you have no experience with variables). And concatenate into that string variable the desired lines separated by a new line character.

0 Likes

Hi Ido,

I'd be happy, if it's that simple.

The main report is connected to the access database and shall contain all contact data (name, date) in its detail band.
This part is easy and works.

But: The value of "courses" (c1, c2,, c3, ...) shall be splitted into pieces. Then diffent information shall be displayed for each of that pieces.

1. The Text "C1" in bold font
2. "Icons" (no images, but text using a symbolic font)
3. the descption of the course.

+---------------------------------------------------+
| name | date | main report, vertical
+---------------------------------------------------+ | C1-Title (bold) | C2 Title | C3.... | subreport, horizontal layout | C1 Icon (different font) | C2-icon | | | C1 description | C2-Descr | | +---------------------------------------------------+ | name | date | +---------------------------------------------------+ | C1-Title (bold) | C2 Title | C3.... | | C1 Icon (different font) | C2-icon | | | C1 description | C2-Descr | | +---------------------------------------------------+

it's wanted to display formatted data, which usually requires a subreport.

The detail band in the subreport shall be processed for each comma separated value von courses - one detail process for c1, again for c2 and so on, if the are more like "c1, c2, c3, c4, c5".

The horizontal output can be switched in the subreport.

If I create an xml file myself (i did for a test) all would work as wanted / expected. But since I'm unable to create this xml file during runtime, I have no idea how to do that.

The xml or string arrays used as datasources were just ideas. Using the subreport like that is based on experience with jasper reports in a complete independent, different project. But I just can't figure out any way to handle this in crystal reports.

It's similar to a receipt with several products where you don't have the data for the products as rows, but only one row in the data per receipt, holding all product numbers comma separated in one column.

ido_millet
Active Contributor
0 Likes

Simply use the MS Access database as the data source.

No need for acrobatics.

0 Likes

The datasource provided from the third party software is a ms access db. From that one I get the data as shown in the example. Since it's comming from third party I'm unable to change the contents or data provided.

So my idea was to use variables to store (manipluated) data and use that as datasource in a subreport.

ido_millet
Active Contributor
0 Likes

It's not very clear but it sounds like you need to use a CSV file as a data source.
You can set that up using a text ODBC driver.

0 Likes

Hi Kai,

CR is not capable of formatting data sources into parts. You would nee to ask the makers of the XML files to do this for you.

Use Groups in the C1, CR fields and the rest should fall under then.