I've got one problem.
I've got a report with a SQL-query, which includes one field, which is filled with a CSV-string. Usually we build our reports in the designer, but in this case it is not possible.
Now this CSV-string should be displayd as a table or databand within the report. So I've tried to add this in the Code-tab.
I've got this c# code so far:
Code: Select all
public void CSVimport(string csv)
{
MessageBox.Show(csv); // test if the csv-string is here
DataTable dt = new DataTable("CSVdataset");
string[] lines = csv.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
for(int i = 0;i < lines[0].Split(';').Length;i++)
{
dt.Columns.Add(lines[0].Split(';')[i]);
}
foreach (string line in lines)
{
string[] cells = line.Split(';');
DataRow dr = dt.NewRow();
//for (int i = 0; i < cells.Length; i++)
//{
// dr[i] = cells[i];
//}
dt.Rows.Add(cells);
}
DataSet ds = new DataSet("CSVdataset");
ds.Tables.Add(dt);
this.DataBand2.DataSourceName = "CSVdataset"; // data is not shown in the report
StringWriter sw = new StringWriter();
ds.WriteXml(sw);
string result = sw.ToString();
MessageBox.Show(result); // just to test it, if the csv.string is in the dataset
//this.Render();
//return ds;
}
Thank you!
KR
Alex
PS: I use Stimulsoft Reports.Net Version 2013.2.1700 from 19 September
.Net Framework v2.0.50727