Passing Data to reports

Stimulsoft Reports.Flex discussion
Dom
Posts: 9
Joined: Tue Sep 14, 2010 11:11 am

Passing Data to reports

Post by Dom »

Hi,

This is a great product which is just what we're looking for. I've designed a report with a sample data set. How do I pass the actual data (XML) to the report at runtime? I can only see an example of how to pass a filename which is not very practical in a web application...

Thanks in advance
Dom
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Passing Data to reports

Post by Alex K. »

Hello,

You can see the article in our knowledgebase:

http://stimulsoft.helpserve.com/index.p ... ticleid=63

Thank you.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Passing Data to reports

Post by Vladimir »

Hello,

Unfortunately, at this moment you can load the data only from XML file. In the release version, which will be in end of September within two weeks, will be able to load data from XML variables, and also from table structures, formed from the code.

Thank you.
trademark16
Posts: 20
Joined: Sun Aug 29, 2010 2:56 am
Location: Buffalo, NY

Passing Data to reports

Post by trademark16 »

Has the ability to pass data from XML varilables happened yet?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Passing Data to reports

Post by Vladimir »

Hello,

Yes, it is already available in the new release 2010.2 Reports.Fx for Flex.


Method registers XML data source in the report:

Code: Select all

report.regDataXml(name: String, dataNode: XMLNode, schemaNode: XMLNode = null): void
Method registers a created data source in the report:

Code: Select all

report.regDataSet(name: String, alias: String, dataSet: DataSet): void
Use the following code to create a data source:

Code: Select all

var table: DataTable = new DataTable("Customers");
var column: DataColumn = new DataColumn("CustomerName", StorageType.StringType);
table.columns.add(column);

table.addNewRow().sett("CustomerName", "John Smith");
table.addNewRow().sett("CustomerName", "Antonio Moreno");
table.addNewRow().sett("CustomerName", "Elizabeth Brown");

var dataSet: DataSet = new DataSet("DataSetName");
dataSet.tables.add(table);

var report: StiReport = new StiReport();
report.regDataSet("DataSetName", "DataSetName", dataSet);
report.dictionary.synchronize();
report.design();
Thank you.
Dom
Posts: 9
Joined: Tue Sep 14, 2010 11:11 am

Passing Data to reports

Post by Dom »

Hi,

Just wondering why are you using XMLNode here rather than XML? Is there a way of passing an XML class or do we need to always convert to XMLNode?

Thanks
Dom
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Passing Data to reports

Post by Vladimir »

Hello,

We used XMLNode type as a data adapter works with XMLNode. We will add the method to work with XML type.

Thank you.
guibi
Posts: 10
Joined: Sun Sep 12, 2010 10:24 am
Location: France

Passing Data to reports

Post by guibi »

Hi Dom,

Use the function to convert XML or arraycollection to xmlNode

protected function objectToXML(obj:Object,myString:String):XMLNode {
var qName:QName = new QName("root");
var xmlDocument:XMLDocument = new XMLDocument();
var simpleXMLEncoderNeu:SimpleXMLEncoderNeu = new SimpleXMLEncoderNeu(xmlDocument);
var xmlNode:XMLNode = simpleXMLEncoderNeu.encodeValue(obj, qName, xmlDocument, myString);
return xmlNode;
}

report.regDataXml('data1', objectToXML(MyArray.source,"data1"),null)
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Passing Data to reports

Post by Vladimir »

Hello,

We added a new functions:

Code: Select all

public function regData(name: String, alias: String, data: Object): void
public function regDataTable(name: String, alias: String, dataTable: DataTable): void
public function regDataSet(name: String, alias: String, dataSet: DataSet): void
public function regDataXML(name: String, alias: String, data: XML): void
public function regDataXMLNode(name: String, alias: String, dataNode: XMLNode, schemaNode: XMLNode = null): void
Thank you.
tonysameh
Posts: 10
Joined: Mon Nov 08, 2010 6:09 am
Location: Egypt

Passing Data to reports

Post by tonysameh »

I am still confused.
I did as Dom said: designed the report using a sample xml data, then saved the report file.

Now I loaded the report using loadDocumentFromString and loaded xml data using regXMLData and it shows an empty report.

I tried using regXMLDataNode and it also shows an empty report.

My complete code is as follows:

Code: Select all

var loader: URLLoader = event.target as URLLoader;
documentString = loader.data as String;
var report: StiReport = new StiReport();
var myXML:XML = 
					
					  
						ALFKI
						Alfreds Futterkiste
						Maria Anders
						Sales Representative
						Obere Str. [size=7]...etc[/size]

var xmlDoc:XMLDocument = new XMLDocument(x1);
report.regDataXMLNode("DataSource1", "DataSource1", xmlDoc.firstChild);
//report.regDataXML("DataSource1", "DataSource1", myXML); // also does not work
report.loadDocumentFromString(documentString);
var rect: Rectangle = new Rectangle(100, 100, 900, 600);
report.showDialog(rect, "Customized ViewerFx", true, true);
Is there a missing step or the order of steps is not correct?
Please help me. Thanks
Locked