Filling up report with data

Stimulsoft Reports.JAVA discussion
Post Reply
glf4k
Posts: 3
Joined: Fri Feb 28, 2020 11:06 am

Filling up report with data

Post by glf4k »

Hello,
I've tried to produce a simple report using the latest Stimulsoft for Java (Trial) and I've ran into a multiple problems.

The example with XML works fine, but the problem is when I attempt to create my own report in code.

I want to pull objects from REST API and show its response in report. But I'm unable to show nothing in the document.
This is simple example I've tried:

Code: Select all

StiReport report = new StiReport();
StiPage stiPage = new StiPage(report);
report.getPages().add(stiPage);
report.setDictionary(new StiDictionary(report));

StiDataTableSource stiDataTableSource = new StiDataTableSource();
DataTable table = new DataTable();

StiDataColumnsCollection col = new StiDataColumnsCollection(stiDataTableSource);
col.add(new StiDataColumn("user.id", "user.id", StiSystemType.getSystemType("System.String")));

table.setColumns(col);
DataRow dataRow = table.createNewRow();
dataRow.addCell("user.id", "TEST");

stiDataTableSource.setDataTable(table);
report.getDictionary().getDataSources().add(stiDataTableSource);

report.render();
and throws:
java.lang.NullPointerException com.stimulsoft.report.dictionary.dataSources.StiDataSource.setDataTable(StiDataSource.java:1502)

does anyone know where the problem could be? Or is there a way to render report without using Database Data Source? I would like to somehow render List<Entity>. or is there a tutorial for that?
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: Filling up report with data

Post by Vadim »

Hello.

You need to stiDataTableSource.setDictionary(report.getDictionary()); before stiDataTableSource.setDataTable(table);
You can use sample https://www.stimulsoft.com/en/samples/j ... in-runtime
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Re: Filling up report with data

Post by Andrew »

Hello,

How are you? Was the Vadim's suggestion helpful?
Post Reply