RegisterData empty?

Hi all,


I'm trying to create a report with a licensed version of FastReport.NET.

But even a simple 'RegisterData' isn't working.

The report used is an empty report, I see the newly 'created' datasources in the report designer but they remain empty.

:(

What am I missing here? Many thanks for the help




Comments

  • What are you hoping to see?

    everything looks good

    I share with you this sample code for generate PDF Report with .Net.


    I hope this code can help you.

     private static void GeneratePDFReport(int invoiceIndex)

        {

          // PDF Result

          PdfSharp.Pdf.PdfDocument pdfFull = new PdfSharp.Pdf.PdfDocument();

          // Fast Report Object

          Report fastReportObject = new Report();       

          // Dataset Object Data (Empty)

          DataSet dataSetschema = new DataSet();              

          //Source tables and columns

          XmlSchemaSet schemaSet = new XmlSchemaSet();

          XmlTextReader reader = new XmlTextReader("InvoiceSchema.xsd");

          var invoiceSchema = XmlSchema.Read(reader, null);

          schemaSet.Add(invoiceSchema);

          schemaSet.Compile();

          dataSetschema = ToDataSet(schemaSet);

                 // XML Data to fill data source

          XDocument xdoc = XDocument.Load($"invoice{invoiceIndex}.xml");

                 // FILL DATASOURCE with XML data

          dataSetschema.ReadXml(new MemoryStream(Encoding.UTF8.GetBytes(xdoc.ToString())), XmlReadMode.ReadSchema);

          // Load FRX

          fastReportObject.Load("FRX_Design.frx");      

          //Register DATA

          fastReportObject.RegisterData(dataSetschema);       

          // Generate Report

          fastReportObject.Prepare();

          //Export repor to PDF

          var exportpdf = new PDFExport();

          exportpdf.ShowProgress = false;

          exportpdf.Compressed = true;

          exportpdf.Background = false;

          exportpdf.TextInCurves = false;

          exportpdf.PrintOptimized = true;

          exportpdf.ImagesOriginalResolution = false;

          exportpdf.ColorSpace = PDFExport.PdfColorSpace.RGB;

          exportpdf.JpegCompression = true;

          //exportpdf.EmbeddingFonts = false;

          var resultFile = new MemoryStream();

          fastReportObject.Export(exportpdf, resultFile);       

          // This step is not strictly necessary // with de PDF Export you can Save de PDF File

          PdfSharp.Pdf.PdfDocument one = PdfReader.Open(resultFile, PdfDocumentOpenMode.Import);

          for (int i = 0; i < one.PageCount; i++)

          {

            var page = one.Pages[i];

            pdfFull.AddPage(page);

          }

          // Save if it is necesary

          //pdfFull.Save($"invoice{DateTime.Now.ToString("yyyyMMddHHmmssFFFFFF")}.pdf");

        }


    Best Regards

    Jai

  • Hi Jai,


    Thanks for you example, but in this example you create an XML file first?

    Isn't there a possibility to just pass the data from an object?


    Kind Regards,

    Gregory

  • Yes, I never use an object like a data source but Yes! it is possible.

    You can use Json data like a source, an use Newtonsoft to convert object to Json. Another option is fill data set from the object and then use dataset like a data source.

    and sorry, I can´t help more.


    Send me a message.

    F.A.C.E.B.O.O.K jairo.hernandez.9256

    Alias José Hernández.

  • Found a solution:

    Used the same code, but instead of a List<> use a 'DataTable' and it's working now.

    @jerezkyo ; thanks for the input, no doubt this will be usefull for future projects.


    Kind regards,

    Gregory

  • 👍️

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.