Simplicty and flexibility!


New Sample - How to create a text or HTML file for printing in DataEase 8 (Ver. 8.0.0.1308)

Started by DataEase
You will need to Sign In to be able to comment on the Blog!

New Sample - How to create a text or HTML file for printing in DataEase 8 (Ver. 8.0.0.1308)

Download Sample


DataEase for Windows has been a nightmare when it comes to exporting and printing. It seems that this basic need has eluded the high and mighty ;-)

Not so anymore. Popular demand has forced our hand and we have spent some hours creating a small sample to give you an idea on how you can achieve this with DataEase 8 "Native".

The functions we use to achieve this is: MemoWriteToFile(), WriteToFile(), Chr(), MemoExecDQL(), PrintHtml() etc.

So maybe we should start with the results to get you interested:




















Basically what we have done here is to create a couple of files, one pure text that can be printed directly by a printer or edited further in Write etc, and one in HTML that you can edit in our internal HTML editor or simply print directly with our PrintHTML() function.

We have showed earlier how you can generate documents by using functions like MemoCopy(), MemoMemoCopy(), MemoReplace() etc.

What we show here is how to use the corresponding File functions to achieve the same, and add the complexity of adding a listing in the middle of the document which is typical for Invoices and reports...

As you can see, we have also formatted the center body (all of the document in fact) to show you how you can use Text features like tabs etc in Text and all the HTML tagging you want in HTML. 

Beware though. Printing and Emailing HTML is a little particular, so best stick to the basics like Tables etc.

You can however use CSS (a print css) to format fonts etc. We haven't bothered in this sample, as we think we need to leave some of the fun to you ;-)

Download the sample and pick it apart. If there is anything you think you can use, feel free to steal it ;-)

Just to show you how fun this is a quick preview of the DQLs that do the hard job:

define temp "retval" text .
define temp "spacer" text 255 .
define temp "line" text 69 .
spacer :="                                                                                                                                                             " .
line := "-------------------------------------------------------------------------------------------------------------------------" .
for WriteToFile with OrderNr = Data-entry Field1 ;
retval := MemoWriteToFile( Header, data-entry field2, 1)  .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) . . -- Line Change, will be uncessary when we update WritToFile an MemoWriteTofile with option 4 and 5. CR before Append or after Insert.
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(Subject,data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval :=WriteToFile(concat("Productnr",chr(9),"Product Description",chr(9),chr(9),chr(9),"Price",chr(9),chr(9),"#",chr(9),"Total",chr(10),chr(13)), data-entry field2,0) .
retval := WriteToFile(line,data-entry field2, 0) .
for Orderlines with Ordernr = WriteToFile Ordernr ;
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(productNr,chr(9),firstc(concat(Description,spacer),30),chr(9),lastc(concat(spacer,Prices),8),chr(9),lastc(concat(spacer,Count ),3),chr(9),lastc(concat(spacer,Total),10)),data-entry field2, 0) .
end
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(line,data-entry field2, 0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(lastc(concat(Spacer,"Total Order: ", Total Order),69),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(line,data-entry field2, 0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := WriteToFile(concat(chr(10),chr(13)),data-entry field2,0) .
retval := MemoWriteToFile(Footer,data-entry field2, 0) .
This is the DQL that generate the text document.

define temp "retval" text .
for WriteToFile HTML Version with OrderNr = Data-entry Field1 ;
retval := MemoWriteToFile( Header, data-entry field2, 1)  .
retval := WriteToFile("<br>",data-entry field2,0) . -- Line Change, will be uncessary when we update WritToFile an MemoWriteTofile with option 4 and 5. CR before Append or after Insert.
retval := WriteToFile(concat("<h2>",Subject,"</h2>"),data-entry field2,0) .
retval := WriteToFile("<table><tr><th>Productnr</th><th>Product Description</th><th>Price</th><th>#</th><th>Total</th></tr>",data-entry field2,0) .
for Orderlines with Ordernr = WriteToFile HTML Version Ordernr ;
retval := WriteToFile(concat("<tr><td width=",chr(34),"100",chr(34),">",productNr,"</td><td width=",chr(34),"300",chr(34),">",Description,"</td><td width=",chr(34),"150",chr(34)," align=",chr(34),"right",chr(34),">",Prices,"</td>"),data-entry field2, 0) .
retval := WriteToFile(concat("<td width=",chr(34),"50",chr(34)," align=",chr(34),"right",chr(34),">",Count ,"</td><td width=",chr(34),"150",chr(34)," align=",chr(34),"right",chr(34),">",Total,"</td></tr>"),data-entry field2, 0) .
end
retval := WriteToFile("</table>",data-entry field2,0) .
retval := WriteToFile(concat("<p align=",chr(34), "right" , chr(34) ,"><b>Total Order: ", Total Order, "</b></p>"),data-entry field2,0) .
retval := MemoWriteToFile(Footer,data-entry field2, 0) .


Written by DataEase 20/06/13 at 17:51:52 Dataease [{8}]FIVE
DG3_BlogList