Creating reports

Folks,

I need to generate simple reports (<100/mo) like invoices and purchase orders for my app. I do not need analytics or scheduling, just simple reports that will get printed.

I have tried setting up a VM on azure to run SSRS which has been very very painful and now that I am nearly there I have received a huge bill. I only need to be able to create a report with a table and render it as a PDF. I have an MS SQL backend.

Can anyone recommend a better way of doing this? I have throught SSRS would be straightforward (I have used it before) , Power BI seems to require a premium (4k) license to do this.

thanks

John

Hi @johnmu,

You can check https://github.com/FastReports/FastReport - they seem to have a free version. Full disclaimer: I haven't used this project and Radzen Ltd. isn't affiliated in any way with its authors.

Many thanks,

I will check it out and I'll report back with my results and hopefully it will be of use to others as well.

John

Hi, I agree with korchev. FastReport Opensource it's the best solution. it's free and very simple to use.

Here the steps that worked for me:

  1. With the report designer free create the .frx report and save it somwhere.
  2. download with Nuget fastreport opensource and fastreport pdf
  3. Create in your Radzen app a custom controller that return the PDF file of the report.
using FastReport;
using FastReport.Export.PdfSimple;

Report report = new Report();
report.Report.Load("your_report.frx");
string report_dataset_name = "mydataset";
DataTable dat1 = new DataTable();
SqlDataAdapter adapter1 = new SqlDataAdapter();
adapter1.TableMappings.Add("Table", report_dataset_name 
SqlConnection con = new SqlConnection();
con.ConnectionString = yourconnectionstring
SqlCommand cmd1 = new SqlCommand();
cmd1.Connection = con;
cmd1.CommandText = yourquery
cmd1.CommandType = CommandType.Text;
adapter1.SelectCommand = cmd1;
DataSet dataSet1 = new DataSet(nomeds1);
adapter1.Fill(dataSet1);
report.RegisterData(dataSet1);
report.Prepare();

            using (MemoryStream ms = new MemoryStream())
            {
                PDFSimpleExport pdfExport = new PDFSimpleExport();
                pdfExport.Export(report, ms);
                ms.Flush();
                return File(ms.ToArray(), "application/pdf");
            }

then calling the controller you can get the PDF.
to download or to view in the Radzen page using an Iframe.

<RadzenHtml>
      <iframe width="100%" height="800px" src="@(pdfUrlProperty)"></iframe>
</RadzenHtml>

where the pdfurlproperty call you custom controller;

pdfUrlProperty = "http://localhost:5000/api/custom";

I dont know if it's the best way, but for me it worked ...

5 Likes

Keter,

many thanks for this. I have a couple of questions.

  1. When i navigate to the page with the iframe, my code automatically but i would rather it was only when the user pressed a button? Please advise how i can change this.

  2. I have read everything i can on fastreports and downloaded the community edition report builder which works great but I don't undertand why when i run a report do I need to Register the data. The report already contains all the relevant infomation, all the connections and data objects so why can't i just load the report and run it. When i try this it says the various data objects are missing. I can't find anything online which addresses this issue. Please can you advise?

thanks John

Hi,

  1. About the first question I am not sure , but I think that you could try to set the "pdfurlproperty" in the iframe calling a method when you push the button.
  2. FAST REPORT: there are many ways to use it. one way is ,as you say , to let the report designer create the Data connection . in the case of my Radzen application the data connection can change. ( for example I can deploy the application on different server with different SQL databases). even more important in this way I can programmatically build and change the query . To use the report in this way I created a little .NET desktop app that create as in my example the query , connection and register the data. then I open the report designer and I use the dataset created programmatically. then from the Radzen app I use the report as shown before. this give me complete freedom to change query and connection without change the report. but as I said FastReport is very very flexible so there are more than one way to use it. I hope that my answer was a bit helping. best regards .
1 Like

Keter,

I am working round the issue of the report dataset.

I have another issue which I wonder if you might be able to help with. When i register the fastreport nuget packages in Visual Studio, everything works fine but very regularly (sometimes hourly) the packages automatically unistall from VS forcing me to reinstall them. Have you come across this problem?

Thanks

John

sorry , but I never had this problem. maybe it' can be related to some automatic update ?

Hi @johnmu, I am very interested to know if you have made to use FastReport in combination with Radzen. I am currently working on my bachelor's thesis and my job is to find a way to generate reports without using SSRS. Could you please tell me if you have succeeded?

Thanks a lot!
Yannic

Nope, couldn’t get any alternatives to work. For several reasons:

  1. My lack of ability
  2. It’s much more involved than it should be and took too long to research.
  3. Any solutions I did try invariably failed on my deployed app because it’s on Azure. Even though I’m on a std package and shouldn’t have such a constrained sandbox I failed to get anything working.

I have just started to look at fast reports again as they have a blazor version. I’m sure I can get it to work locally but not convinced it will work on azure.

I did try pdfmake and I know it works because it’s used by smart.blazor which I’m using for the Gantt chart component but I havent managed to create my own report in pdfmake.

For something that is so fundamental to software in a work environment it is astounding how difficult this has proved to be and I still don’t have a good solution. SSRS is expensive and very slow to respond if used intermittently it takes ages for the server to wake up(unless I pay an extortionate amount to have a higher availability). So SSRS not a practical solution for me but it’s all ove got at the moment. RDLC reports won’t work on Azure. Grrrrrr.

If you have any thoughts or examples I’d be very interested to see.

Thanks

John

Finally got fastreports to work and on azure too.