Page 1 of 2

Passing Data to reports

Posted: Tue Sep 14, 2010 11:16 am
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

Passing Data to reports

Posted: Wed Sep 15, 2010 1:27 am
by Alex K.
Hello,

You can see the article in our knowledgebase:

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

Thank you.

Passing Data to reports

Posted: Wed Sep 15, 2010 2:04 am
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.

Passing Data to reports

Posted: Sun Oct 03, 2010 8:37 pm
by trademark16
Has the ability to pass data from XML varilables happened yet?

Passing Data to reports

Posted: Mon Oct 04, 2010 1:49 am
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.

Passing Data to reports

Posted: Wed Oct 06, 2010 7:05 am
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

Passing Data to reports

Posted: Tue Oct 12, 2010 7:22 am
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.

Passing Data to reports

Posted: Wed Oct 13, 2010 4:08 am
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)

Passing Data to reports

Posted: Thu Oct 14, 2010 1:24 am
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.

Passing Data to reports

Posted: Sun Nov 14, 2010 4:11 am
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