Hi,
I've created a report in the designer (2016.1), based on a CSV file that was located in a given folder and with a givenname.
If I use the following code a PDF is created as expected...
string folder = @"c:\AxyCodeGen\ASR\Export\";
using (StiReport report = new StiReport())
{
// This is the report template that was created using the Designer. Data in there was bases on NotaData160101000005.csv and from within the Designer I can create a
// beautifull report...
report.Load(Path.Combine(folder, "NotaTemplate.mrt"));
report.Render();
report.ExportDocument(StiExportFormat.Pdf, Path.Combine(folder, "OK.Pdf"));
}
What I want to do however is connect the report to a different CSV file (with of course the exact same structure), but I can't get it to work...
using (StiReport report = new StiReport())
{
report.Load(Path.Combine(folder, "NotaTemplate.mrt"));
string newCsvFileName = "NotaDataNew.csv";
// How do I bind My NotaDataNew.CSV file (of course the same structure as the one that the report was created with)?
//....
report.Render();
report.ExportDocument(StiExportFormat.Pdf, Path.Combine(folder, "NewData.Pdf"));
}
Can someone help me with this please?
Thx in advance & kind regards,
Patrick
Binding to a different CSV file
Re: Binding to a different CSV file
Hello, Patrick!
You can use following code:
Please contact us if you need any help.
Thank you.
You can use following code:
Code: Select all
var report = new StiReport();
report.Load("d:\\report.mrt");
var dataBase = report.Dictionary.Databases["CSV1"] as StiCsvDatabase;
//Change path to the csv folder
dataBase.PathData = "D:\\Stimulsoft\\Stimulsoft.Reports\\Reports";
var dataTable = report.Dictionary.DataSources["Sample"] as StiDataStoreSource;
//Change name of the csv file
dataTable.NameInSource = "CSV1.Sample";//CSV1 - its a name of the CSV Connection in the report dictionary, Sample - its a name of the CSV file in the folder
report.ExportDocument(StiExportFormat.Pdf, Path.Combine(folder, "OK.Pdf"));
Thank you.
Re: Binding to a different CSV file
Hi Jan,
Works like a charm!
Thx very much!!!
Patrick
Works like a charm!
Thx very much!!!
Patrick
Re: Binding to a different CSV file
Hello, Patrick!
You are welcome!
You are welcome!