|
I'll have to give an answer much like the one to Alex Evans below, first of all, how to set up a multi template report:
report.AddTemplate( _T( "header.rpt" ), report.TEMPLATE_TYPE_TITLE_PAGE );
report.AddTemplate( _T( "body.rpt" ), TEMPLATE_TYPE_SECTION );
report.AddTemplate( _T( "summary.rpt" ), TEMPLATE_TYPE_SUMMARY_PAGE );
CStringArray stra;
for( int t = 0 ; t < max ; t++ )
{
stra.Add( somedata);
}
report.Add( _T( "a_grid" ), stra );
report.Print();
If you add the text [%date%] into a field, it will be replaced by the current date when printing, [%page%] will do the same, but with a page number (of course). As you can see in the documentation, there are other special markers as well - some relevant only for grids.
As for a couple of demo reports, *sigh*, time is not enough, I would have to create a demo app filling them with data, and my design skills are frankly not enough to create reports with any kind of acceptable looks
|
|
|
|
|
Thanks a lot for ur time, appreciate it. I will give it a go.
cheers
|
|
|
|
|
Printing with the dialogbox is fine but printing
with CList is difficult and on the top i need to
print a text box data which is the name of the
company
thankin you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I must admit I'm a bit confused here (not that that's anything new). Are you refering to the normal printing of a dialog with controls? Do you want to move data from a CList to a report? A text box is easily created with the Report Creator, either as a label (where you fix the title at design time) or as a text field which you add data to at runtime.
|
|
|
|
|
Hello again
Thanks Johan for clearing my previous question. Now, I am working with a Dialog based application, the dialog is derived from some other class, and I need to print.
All the examples I found until now are one of the following:
1) They are either based on the Doc/View architecture
2) Or Dialog base, and derive the new class from CView
I am in the 2nd group but could not do this, so I only need to be able to print - you sample loop, but without VIEW, just direct printing.
Hope you can tell me what can I do to achive this?Which functions to call, or a code sample
Thanks again for your help
Alex
|
|
|
|
|
The only thing you need is a (printer) CDC, which you can get using for example CPrintDialog::CreatePrinterDC . As a matter of a fact, if you just set up the report, loading it and adding data,, calling CReportGenerator::Print (without inparams) should print the report to the default DC.
|
|
|
|
|
Hello Johan
My mistake, the fill are shows correctly in the Report-Creator preview mode, BUT not at runtime with the Report-Generator, in 6 or in .NET, in both cases te rectangular are comes up empty...
I also have another question.
When for example printing a report / Invoice - you will have some header information on the first page, but NOT on subsequent pages... So how can I control this?
An example will be appreciated
Thanks again
Alex
|
|
|
|
|
As I stated in the answer to your post below, I'll look into the rectangle stuff.
As for a separate title page, you'll want to create two templates, one for the first page, and one for the rest of the pages. Add a grid with the same name on the two templates (data you add to the report will start on the first template, and then spill over automatically repeating the second template as many times as necessary). Call AddTemplate for the two templates instead of SetReportFile .
|
|
|
|
|
Hello again
Tha nks again for your help on this, but I tried several things, and I don't seem to get it right.
Can you please give me some code sample of how to go about it, where in the loop to insert the 2nd AddTemplate?
Thanks
Alex
|
|
|
|
|
Alex,
You are not supposed to add the second template in a loop at all, rather at the beginning, together with the first page. The generator will work out what to put where.
I'll prepare a small project demonstrating this and send it directly to you.
|
|
|
|
|
Thanks Johan
Do you mean, that I need to call SetReportfile() twice... and do all the staff in the loop one after the other or what exactly?
If so, it means that I will need to calculate how many records will fit onto the first page (with the header) and continue loading Add() data from that point onwards onto the 2nd page???
Cheers
Alex
|
|
|
|
|
Even though we have sorted this out, let me answer for the benefits of others.
The report file(s) are loaded before data. For a single report file, SetReportfile is called, for multiple files, AddTemplate is used instead, so:
report.AddTemplate( _T( "header.rpt" ), report.TEMPLATE_TYPE_TITLE_PAGE );
report.AddTemplate( _T( "body.rpt" ), TEMPLATE_TYPE_SECTION );
report.AddTemplate( _T( "summary.rpt" ), TEMPLATE_TYPE_SUMMARY_PAGE );
CStringArray stra;
for( int t = 0 ; t < max ; t++ )
{
stra.Add( somedata);
}
report.Add( _T( "a_grid" ), stra );
report.Print();
|
|
|
|
|
Hello Johan
A couple of things I see, first when compiling under .NET, I get an error (but NOT under MSVC 6.0)
borderline.h(23) : error C4716: 'CBorderLine::operator=' : must return a value
On the following lines
class CBorderLine
{
public:
// Construction/destruction
CBorderLine();
virtual ~CBorderLine();
operator = ( const CBorderLine& line )
{
m_visible = line.m_visible;
m_style = line.m_style;
m_color = line.m_color;
m_thickness = line.m_thickness;
};
=====
2nd issue - when going to Print-Preview under 6.0 I get my rectangular shap filled with green, while under .NET it comes up empty... Here is the RPT file I created, maybe you can figure out what am I doing wrong?
Thanks
Alex
paper:793,1122;
report_label .718750,0.604167,4.531250,0.947917,This is the top of the report,,0,Verdana,200,0,0,0,0,32768,0,1,3317052,2,1242140;;
report_box .645833,1.468750,7.510417,1.875000,,,0,1,0.000000,0,0,1,65280;
report_grid .697917,2.489583,7.541667,11.156250,,Grid,0,1,0.000000,0,0,0,0.000000,0,0,0,0.000000,0,0,6,0.000000##0#0#0#0#0#0#0#;
report_picture:5.572917,0.552083,7.375000,1.062500,Mklogo.bmp,,0,1,0.000000,0,0,C\colon\ReportGen\Mklogo.bmp;
report_field:6.677083,2.083333,7.468750,2.291667,,InvoiceNum,0,Times New Roman,120,0,0,0,0,0,0,5,3317052,2,1944715424;;
|
|
|
|
|
Congratulations!, this work are fine
Question: How i can call generator or creator from VB6, there is way to build dll from your code, someone has dll's that i can call from vb6.
Thank you!
|
|
|
|
|
Thanks for the feedback!
On how to use from VB, I must admit being at a loss. As the data types used, CString and so on, are MFC, I assume it would be a bit tricky to build a wrapper DLL (or perhaps not), but I really don't know.
The report editor is an even bigger problem in this respect, an OCX would have to be rather extensive in wrapping the different settings and so on into properties.
I would support someone doing the effort, but know nothing at all of VB myself, and would not take on this task myself.
|
|
|
|
|
Hi Johan,
I wrote last week with a similar request.. ("Just can't believe it")
I guess that the Report Editor wouldn't be converted or wrapped, we the VB6/ASP 3.0 programmers could use it "as it is" right now. But the main goal is to wrap the Report Generator code...
I could take the risk in my free time, but off course, I will need your help. In such case, maybe this wouldn't be the right place to ask you about a specific programming task like this... If you don't mind contact me at jeanpaul_mir@cantv.net.
Regards
Jean Paul Mir V.
|
|
|
|
|
Hi,
I found a little bug when creating a grid in the report Editor
The size information is Not accurate.
To fix this lillte bug
change the PixelsToCentimeters as following...
double CUnitConversion::PixelsToCentimeters( int pixels )
/* ============================================================
Function : CUnitConversion::PixelsToCentimeters
Description : Converts from pixels to centimeters.
Access : Public
Return : double - Resulting centimeters
Parameters : int pixels - Pixels to convert
Usage : Call to convert from pixels to centimeters
============================================================*/
{
double pixelspercentimeter = static_cast< double >( CUnitConversion::s_resolution ) / 2.54;
return static_cast< double >( pixels )/pixelspercentimeter ;
}
This is a light contribution to your fantastic work
Thanks,
|
|
|
|
|
Thanks for the contribution - the list of small fixes and additions is making an update necessary soon
|
|
|
|
|
I've downloaded your code a few weeks ago and saved it in my "Don't forget to see again cause it's good" folder...
Now that I had time enough to see it I'm really surprised, I mean, Your code rocks!... This is something like "get CR source code by accident" but only with the functionality that I need... not more not less... what more can I say?... Thanks for that!
Finally... 2 things:
1.- I have to recognize your disposition to answer all posts related with your code and, over all, the way you do... Is good to find people like you on internet. Once again... THANKS A LOT (and this is not an argument to help
2.- I'm a VB/ASP/VB.Net/ASP.Net programmer... even when I've done some work with c++, I don't consider myself a c++ Programmer, that's why I decided to ask you first. I'd like to have that functionality on a Web page, and when I saw your code the first thing that comes to my "humiliated-by-your-code" mind was ATL to make some sort of OCX encapsulating the Report Generator Code...
This could be possible? or I'm just having some kind of weird fantasies?
Regards
PS: Sorry about my english...
Jean Paul Mir V.
http://www.gruposid.com
|
|
|
|
|
Thanks for the nice feedback!
1. Thanks for the feedback again
2. Everything is possible, of course. I'm relying on MFC for lots of stuff, but the most involved part is probably to get rid of CString and CStringArray , as well as CObArray which I use to store objects. It will take time to do this, however, time which I just don't have. Anyone feeling up to the task
PS: I'm not a native English speaker either, and you would have fooled me if you would have skipped your PS.
|
|
|
|
|
Hi Johan,
First of all, thanks for your fabulous work;)
It worked at once.( under VC++ 6)
I have no problems in Simple Dialogs, and SDI.
But when i use a MDI environnement, the output doesn't work well
I use two templates with some data.
For instance i draw a line crossing a circle, in MDI the output shows the line above the circle.
in MDI Some fields aren't shown.
In fact the result of the output is very different from what appears in the Report Creator Module.
Unhappily i intend to use the report in MDI...
If you have any idea . I can send you the output. ( my printer is Adobe acrobat Distiller )
Best regards,
Daniel
|
|
|
|
|
Thanks for the feedback!
To simplify my bug-hunting, I would much prefer if you sent the file you saved from the report creator exhibiting the problem.
|
|
|
|
|
Hi,
Thank you for your answer
Here is the files generated with ReportCreator
first One
paper:793,1122;
report_label:2.104167,3.468750,5.166667,3.895833,Cher Client\comma\newlineVoici votre relevé concernant les opérations,TEXTE_1,0,Times New Roman,120,0,1,0,0,0,0,1,10276524,2,1242292;;
report_box:5.854167,1.541667,6.854167,2.354167,,,0,1,0.000000,0,0,1,255;
report_line:2.375000,1.812500,7.552083,1.812500,,ligne2,0,0.031250,0,65280;
report_field:5.729167,2.437500,6.895833,2.770833,,Adresse,0,Times New Roman,120,0,0,0,0,0,1,4,10276524,2,1944053136;;
report_label:1.135417,2.854167,4.416667,3.072917,texte,,0,Times New Roman,120,0,1,0,0,0,0,5,10276524,2,1944053136;;
report_field:4.218750,9.781250,6.250000,10.239583,,#P1,0,Times New Roman,120,0,0,0,0,0,1,6,10276524,2,1944053136;;
report_field:1.625000,9.781250,3.656250,10.239583,,#D1,0,Times New Roman,120,0,0,0,0,0,1,7,10276524,2,1944053136;;
report_grid:1.177083,4.364583,7.739583,9.552083,,Grid,0,1,0.000000,0,0,1,0.000000,0,0,0,0.000000,0,0,4,1.572917#Times New Roman#120#0#0#0#0#0#0#colonne1|3.937500#Times New Roman#120#0#0#0#0#0#0#c2;
report_ellipse:1.041667,1.708333,1.895833,2.468750,,,0,1,0.000000,0,0,1,65280;
here is the second one
paper:793,1122;
report_grid:1.187500,1.010417,7.427083,10.010417,,Grid,0,1,0.000000,0,0,1,0.000000,0,0,0,0.000000,0,0,4,1.572917#Times New Roman#120#0#0#0#0#0#0#colonne1|3.937500#Times New Roman#120#0#0#0#0#0#0#c2;
report_field:5.395833,10.406250,7.364583,10.864583,,#P,0,Times New Roman,120,0,0,0,0,0,1,2,10790620,2,1944053176;;
report_field:1.218750,10.395833,3.250000,10.854167,,#D,0,Times New Roman,120,0,0,0,0,0,1,3,10790620,2,1944053136;;
I hope they will be useful.
Best regards
Daniel
|
|
|
|
|
I created a rough MDI-project based on the SDI-demo from this article, and couldn't reproduce the problem - perhaps you could mail me a minimum project exhibiting the error for further analysis?
|
|
|
|
|
Thats all man youve made a GREAT work...
You have got a new fan!
|
|
|
|
|