FastReport fetch data

I have this project on c# windows forms and what I have to do is get some data from a web service and present them to FastRaport. I have tried display them on a DataGridView first and then fetching the data from it and it works pretty nice. I can download the file and then it gives me a dialog asking me in what format do I want to save it. But now the requirement is to not use gridview at all, just a button that would convert directly those data into a PDF file.

 Can you please help me with a pseudo code at least or a reference link or something? I would really appreciate it.

Comments

  • Here's my code for displaying the data into DataGridView:

     var asd1 = dataGridView1.Columns.Add("DrzavaAng", "DrzavaAng");
        var asd2 = dataGridView1.Columns.Add("Valuta", "Valuta");
        var asd3 = dataGridView1.Columns.Add("Oznaka", "Oznaka");
        var asd4 = dataGridView1.Columns.Add("Nomin", "Nomin");
        var asd5 = dataGridView1.Columns.Add("Sreden", "Sreden");
        for (var i = 0; i<xmlNodes.Count; i++)
        {
            var node = xmlNodes[i];
            var states = new Class();
    
            states.Valuta = node["Valuta"].InnerText;
            states.Oznaka = node["Oznaka"].InnerText;
            states.Nomin = node["Nomin"].InnerText;
            states.Sreden = node["Sreden"].InnerText;
            states.DrzavaAng = node["DrzavaAng"].InnerText;
    
            //var asd = dataGridView1.Columns.Add("1", "1");
            _ = dataGridView1.Rows.Add();
            dataGridView1.Rows[i].Cells["DrzavaAng"].Value=states.DrzavaAng;
            dataGridView1.Rows[i].Cells["Valuta"].Value=states.Valuta;
            dataGridView1.Rows[i].Cells["Oznaka"].Value=states.Oznaka;
            dataGridView1.Rows[i].Cells["Nomin"].Value=states.Nomin;
            dataGridView1.Rows[i].Cells["Sreden"].Value=states.Sreden;
        }
    

    Here's the part where I pass the data from GridView to the FastReport "database".

    using (Report report = new Report())
            { 
                report.Load(ReportPath);
                DataTable dt = new DataTable();
                foreach (DataGridViewColumn cl in dataGridView1.Columns)
                {
                    dt.Columns.Add();
                }
    
                object[] clvl = new object[dataGridView1.Columns.Count];
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    for (int i = 0; i<row.Cells.Count; i++)
                    { clvl[i] = row.Cells[i].Value; }
                    dt.Rows.Add(clvl);
                }
                DataSet ds = new DataSet();
                ds.Tables.Add(dt);
                report.Dictionary.RegisterData(ds.Tables[0], "test", true);
    
                report.SetParameterValue("date", dateTimePicker1.Value.ToString("dd.MM.yyyy")); 
                report.Show();
            }
    

    My question is, how can I make it to fetch the data without the gridview, directly from webservice and load it into a FastReport -> PDF file?

Leave a Comment