简体   繁体   中英

How do I pass parameters to Windward DocGen?

I need to pass parameters (variables) in to my document template when running a report. How do I do this? I am using the .NET version of Windward.

You pass the parameters in by attaching them to each datasource. You can set a different set of parameters and values for each datasource.

You do this by creating a WindwardInterfaces.net.windward.api.csharp.KeyPairDictionary that contains the parameters. The key is a String with the variable name. The value can be a String, Number, or DateTime. The value type should match database column types if the variable will be used as a parameter in a select.

These are set in the datasource by assigning to the IReportDataSource.Map property. AdoDataSourceImpl and XmlDataSourceImpl both implement IReportDataSource.

IReportDataSource datasource = new XmlDataSourceImpl("data.xml");
KeyPairDictionary map = new KeyPairDictionary();
map.Add("now", DateTime.Now);
datasource.Map = map;

Note that variables are carried across datasources if multiple datasources are applied to a template. If a variable is set in the first datasource, and is not set in the second, it will retain its value from the first. If it is set in the second, that will override the saved value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM