Recent

Author Topic: [SOLVED] Exporting StringGrids for use by LazReport  (Read 5480 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
[SOLVED] Exporting StringGrids for use by LazReport
« on: March 28, 2015, 11:19:25 pm »
First question : Is it possible to use a StringGrid as a datasource in LazReport? I ask because I have a program that has several tabs, and in each are several stringgrids. I don't have a database, and all the documentation and demos seem to show use of LazReport only with databases. If it is possbile to import StringGrid content into a LazReport, could anyone guide me?

Second question : Assuming that the answer to question 1 is no, it is not possible, then I gather it is possible to use a temporary memory resident database structure using TMemDataset from the Data Access tab (as Laksen pointed out to me in IRC). So I could have a button that, when pressed, loads the content of the stringgrids into the database which is then used as the partner object of LazReport. However, I'm not entirely clear on how that works either? What would be the method of loading all the rows and column of one or more stringgrids into a MemDataSet? This demo is useful but I imagine applying that to a stringgrid with 10 columns and say a thousand rows might be confusing (http://www.pp4s.co.uk/main/tu-db-memdataset.html).

Also very comprehensive is http://wiki.freepascal.org/How_to_write_in-memory_database_applications_in_Lazarus/FPC but again, no mention of StringGrid.

As it stands, I am thinking that a method is :

1) Use sg.savetocsvfile('output.csv')
2) Use MemDataSet.LoadFromCSV('output.csv') to load the saved stringgrid content to the data set
3) Use the MemDataSet for the LazReport linking
4) Generate the Report

But this seem like rather a lot of input\output when the data is already in the StringGrid and I just want to export it to a report using LazReport

Thanks for any guidance
 
« Last Edit: March 29, 2015, 12:34:22 am by Gizmo »

paweld

  • Hero Member
  • *****
  • Posts: 1003
Hi,
In attachment is simple project that demonstrate how to generate report from string grid
Best regards / Pozdrawiam
paweld

ttomas

  • Full Member
  • ***
  • Posts: 245
You can check TfrUserDataset component.
Set events on TfrUserDataset and use event OnGetValue from TfrReport.
It's the same as FastReport, you can find help file from FastReport.

Gizmo

  • Hero Member
  • *****
  • Posts: 831
paweld : thankyou very much for your demo, which really really helps. Using it as a basis, I think I will be able to work out how to implement LazReport with my program. Thankyou.

FastReport looks good and thanks for the suggestion, but at $250, I think I'll stick with the Lazarus implementation which looks really comprehensive for what I need.

ttomas

  • Full Member
  • ***
  • Posts: 245
Re: [SOLVED] Exporting StringGrids for use by LazReport
« Reply #4 on: March 30, 2015, 11:10:11 am »
Gizmo, LazReport is fork of free version of FastReport v.2.32=FreeReport for Delphi
http://sourceforge.net/projects/freereport/
Documentation of FreeReport(FastReport) can help you to start. You can download help files and samples from sourceforge.

 

TinyPortal © 2005-2018