Create Reports similar to Access
-
I really have no experience when it comes to creating documents for printing. Actually, I do not know anything when it comes to writing code for printing. For example, in a database application which I wrote about a year and half ago I would like to add the capability of creating reports similar to those in Access. I do not know from where to begin. Do I just create a window and then I add text and lines to it and then send that window to a printer? This is the only idea that pops into my head but it sounds so inefficient. Is there a place online where I can read some tutorials? It doesn't really have to be about creating reports but something similar about creating documents and printing them. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
-
I really have no experience when it comes to creating documents for printing. Actually, I do not know anything when it comes to writing code for printing. For example, in a database application which I wrote about a year and half ago I would like to add the capability of creating reports similar to those in Access. I do not know from where to begin. Do I just create a window and then I add text and lines to it and then send that window to a printer? This is the only idea that pops into my head but it sounds so inefficient. Is there a place online where I can read some tutorials? It doesn't really have to be about creating reports but something similar about creating documents and printing them. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
You've got lots of choices, but it depends on what dependancies you can afford to introduce into your software. If you already have the reports in access how about using access via the COM automation interfaces. Alternatively word automation is probably easier to get started with, especially if you want to construct temporary html files and then load them in word, or use ShellExecute api to print. If clients can't be guaranteed to have office you could also use IWebBrowser2 and related interfaces (perhaps IHTMLWindow3) to provide a low dependancy (only the standard internet explorer control) printing method - I haven't used this approach but I don't see it being too hard. Another report generation idea is to convert the results of queries to xml and then use xslt as a flexible and extensible formatting system. Alternatively MFC has extensive documentation on printing.
If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts your aim; Yours is the Earth and everything that's in it. Rudyard Kipling
-
I really have no experience when it comes to creating documents for printing. Actually, I do not know anything when it comes to writing code for printing. For example, in a database application which I wrote about a year and half ago I would like to add the capability of creating reports similar to those in Access. I do not know from where to begin. Do I just create a window and then I add text and lines to it and then send that window to a printer? This is the only idea that pops into my head but it sounds so inefficient. Is there a place online where I can read some tutorials? It doesn't really have to be about creating reports but something similar about creating documents and printing them. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
Printing is very similar to drawing on the screen - you use a device context and draw to it. The only thing you really have to watch out for is separating the documents into pages (CDC::BeginPage() and CDC::EndPage() in MFC) and remember that the printing resolution is a lot higher than the screen, so use CDC::GetDeviceCaps() to get the DPI of the printer. Use CPrintDialog to show the print dialog to the user, and the dialog also returns a device context for the printer which is already setup, so all you'll need to do is draw to the DC. Have a look at the documentation for more info, but it really is actually quite easy.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
I really have no experience when it comes to creating documents for printing. Actually, I do not know anything when it comes to writing code for printing. For example, in a database application which I wrote about a year and half ago I would like to add the capability of creating reports similar to those in Access. I do not know from where to begin. Do I just create a window and then I add text and lines to it and then send that window to a printer? This is the only idea that pops into my head but it sounds so inefficient. Is there a place online where I can read some tutorials? It doesn't really have to be about creating reports but something similar about creating documents and printing them. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
In addition to the previous advice, you would do well to search for articles on codeproject by its defacto printing guru Roger Allen[^]. He has quite a few printing articles, with and without views, etc. He's also a nice chap, but tell him I said that. He'll get big headed. Iain.
-
I really have no experience when it comes to creating documents for printing. Actually, I do not know anything when it comes to writing code for printing. For example, in a database application which I wrote about a year and half ago I would like to add the capability of creating reports similar to those in Access. I do not know from where to begin. Do I just create a window and then I add text and lines to it and then send that window to a printer? This is the only idea that pops into my head but it sounds so inefficient. Is there a place online where I can read some tutorials? It doesn't really have to be about creating reports but something similar about creating documents and printing them. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
Hi Toni If you want to make more complex reports, i would suggest to check the functionality of some report systems like list&label or crystal reports. I especially know list&label and you can create your reports almost with drag and drop and fill them with data.
-
I really have no experience when it comes to creating documents for printing. Actually, I do not know anything when it comes to writing code for printing. For example, in a database application which I wrote about a year and half ago I would like to add the capability of creating reports similar to those in Access. I do not know from where to begin. Do I just create a window and then I add text and lines to it and then send that window to a printer? This is the only idea that pops into my head but it sounds so inefficient. Is there a place online where I can read some tutorials? It doesn't really have to be about creating reports but something similar about creating documents and printing them. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.