Page 1 of 1

What is the best reporting mechanism!

Posted: Wed Jan 10, 2018 3:23 pm
by tomay3000
Hello,
It would be very nice if only wxWidgets have OpenXML SDK alike for C++ reporting, but unfortunately OpenXML is for .Net development
whereas wxHtmlEasyPrinting is very limited, it is useful for static templates only.
What if I want to print an undefined number of rows from the database in HTML format, what is the solution then ?
Thank you for your understanding.

Re: What is the best reporting mechanism!

Posted: Wed Jan 10, 2018 5:18 pm
by ONEEYEMAN
Hi,
Well, there is an XML parser in wxWidgets, but I guess you are looking for something more...

Thank you.

Re: What is the best reporting mechanism!

Posted: Wed Jan 10, 2018 7:53 pm
by eranon
Hello, It's not clear (what you want) for me... Do you want to parse an XML file, generate an HTML one or print it?

Re: What is the best reporting mechanism!

Posted: Wed Jan 10, 2018 10:46 pm
by tomay3000
Well, What I want exactly is reporting like "SAP Crystal Reports" or "Fast Reports" for printing, so my first thought was about preparing the report template using Office and choose placeholders in the document that should be replaced with the database record values (like @NAME@, @B_DATE@, @ADDRESS@, @PHONE@ and so on), since a .docx document is actually a zip compressed file containing xml files that contains the actual values to be replaced (I open the .docx file which is actually a .zip file, then open the .xml file containing the data to be replaced (@NAME@, @B_DATE@, ...), then get the record values that should be previewed from the database, then do a search and replace of all the placeholders, and finally print-preview or print the document). This method is complex and difficult to implement.
So I went for a different approach when I discovered wxHtmlEasyPrinting, which implies preparing the report template (the preview) with HTML rather than a .docx office file.
I find wxHtmlEasyPrinting much more simpler, but it is very limited.

The problem here, is what to do about reports that have dynamic (no static), (no defined) number of HTML table rows on reports that contains tables?

Or are there any easy to use, updated reporting system (SDK) for wxWidgets I don't see ?

Thank you for your understanding.

Re: What is the best reporting mechanism!

Posted: Wed Jan 10, 2018 11:08 pm
by ONEEYEMAN
Hi,
Yes, docx files are a zip files that contains some XML.
However Word documents are probably not what you want since reporting the data is not the same as Word processor.
wxHTMLEasyPrinting is limited in that it supports only HTML 4 limited set of tags.

You may try to look at the wxWebView for form generation and then use printing capabilities of the browser.
Or you can try to create some web page with placeholders and just run the query and placing the data on that page.

But you will still need either the external browser or wxWebView.

Unfortunately there is no CrystalReport-like/PowerBuilder-like/Access-like software written with wxWidgets.
You can try executing Access as an external program and run the appropriate report with the data retrieved. But this is Windows-only solution.
You can also install MS Office on OSX and use Access there to generate an appropriate report.

Unfortunately I don't think anything is freely available for Linux.

Thank you.

Re: What is the best reporting mechanism!

Posted: Thu Jan 11, 2018 4:27 pm
by eranon
I think you overthink the topic, tomay3000.

A simple HTML template with three parts: header, row, footer, then you duplicate populated row as many time as necessary. At the end, you concatenate these three parts in a wxHtmlWindow (lighter than wxWebView which become really necessary if your report is with complexe layout and/or need for javascript).

Another direction would be to populate a wxRichTextCtrl, but even if the implementation would be different, the main logic remains the same : template with fixed and variable parts...

And, of course, as ONEEYEMAN, I think you should forget the docx (unless you want to produce final document for sharing with persons supposed to load it in Word, WPS Writer, etc.)

Re: What is the best reporting mechanism!

Posted: Thu Jan 11, 2018 11:52 pm
by tomay3000
Well, I guess HTML (using wxHtmlEasyPrinting or wxHtmlWindow sticking with only HTML 4 will do the job) will be the best approach to implement Reports, and you are right, I should forget about .docx files.
Whereas for the three parts of the HTML template, I guess I will implement another approach, which is as follows:
1) Create 1 Single HTML template which will be the final report view.
2) Define BEGIN and END marker variables for dynamic parts like tables. (@BEGIN_TABLE_1@, @END_TABLE_1@, ...).
3) Get the SQL database rows data upon the search criteria into a C++ defined variables.
4) Load the HTML template from resources or file storage into a wxString.
5) Do a search and Replace in the HTML string.
6) Delete every BEGIN and END marker, because we defined them for the dynamic parts purpose.

Thank you all for the support you provide ;)