I use MySQL as my back end database and HMG as front end GUI.
Whenever I raise a SQL query, I populate the results in a grid and if the user wants to print the data, I call a small module called Grid2Print. With the new Harbour RC I am planning to extend this feature to PDF also.
Now, I am showing the screenshot and the module syntax for you. Give me any suggestions that may come to your mind and as Roberto told, we can have a generic method to print a grid.
This is the screenshot of my module now.
The syntax is as follows:
Code: Select all
Grid2Print(cGridName,cWindowName,aHeaders,aSizes,aTypes,cHeader1,cHeader2,cHeader3,nFontsize,cOrientation,lShowWindow)
cGridName : Name of the Grid control
cWindowName: Name of the parent window
aHeaders : Headers of each column in the grid in an array of characters. (Is there anyway to retrieve the headers of a grid?)
aSizes : Sizes of each columns (Here too width of the columns we can't retrieve as a property. This can be changed before printing as the user desires)
aTypes : Type of each column as a single character array (e.g.: {"C","N","D","L"}
cHeader1..3 : Some headers for the report.
nFontsize: Basic Fontsize through out the report
cOrientation: either "P" for portrait or "L" for Landscape
lShowWindow: Logical value whether or not to show the above window to the user while runtime. If selected .f., this window is not shown and with default values, grid data is directly given to the HMG printer module and preview is shown.
Some points:
1. Total width of the paper (in mm) is converted into number of columns by an average formula which uses the fontsize in points (72 points per inch). However, the width of each character is not fixed and in hbvpdf library I had seen a function to calculate this. So, I am working on that. If anybody have already worked on that please throw some light on this.
2. Some columns can be eliminated by the user himself (as mentioned as X) by double clicking the column name.
3. Only when the total width to be printed is less than the total width available, the print button is enabled.
4. The size of the column can be changed by clicking the edit button after selecting the corresponding column name.
5. Lengthy lines can be either truncated or word wrapped.
To be implemented:
1. Now I have a fixed margin of 20 mm from all the sides. This can be made user definable.
2. I had selected Arial as the default font. This too can be given to the user's option.
3. Instead of column size in number of characters, I plan to make it as given in millimeters.
Now, I am just awaiting for your replies.