Dynamically generating data pages with VFP (i.)

Source: Internet
Author: User
Tags print format microsoft frontpage

Say in front

A few days ago a netizen asked: "What report" Save as HTML effect will be such a bad, what form lines, graphics are gone, even the most basic layout effect are gone! Is there any way to solve it?

This question needs to be thoroughly answered, and I would like to answer the following questions:

    1. Clear understanding of the meaning of the *.frx file, *.frx file is actually a table file (DBF), all the report settings are recorded in it. Theoretically, it should be possible to interpret this document, which is actually a very troublesome thing.

    2. The interpreted information is expressed in HTML language and sent into a *.htm file.

    3. Information extraction in a common field, which is a very disturbing thing. How to read the pictures from the field and in BMP, JPG, GIF format saved for Web page calls, I am afraid this will be a half-day headache.

I write this article, will avoid the first, third problem. In other words, the method I introduced cannot parse *.frx files and automatically generate HTML files according to their settings. We only discuss how to easily generate data pages in Visual FoxPro, and this page needs to be designed in advance, just to fill in the data in the run.

I believe: in your project in this way for each report to pre-set a paragraph of "Save as HTML" code, it will be a lot of color!

It is important to mention that the approach described in this article is actually an integral part of the Visual FoxPro Web solution. You can imagine that an Internet service program receives a client directive and, as required, will quickly generate a *.htm file (Web page) and return it to the client's browser. (Note: This is just one of the Visual FoxPro WEB solutions!) )

Customize the code for this report to generate a page

Understanding the economic implications of Product Inventory

This report is called "Product Inventory Reports" and is selected from the Visual FoxPro "sample code." The following is its Design view:

Its data comes from the "Products" table, and in this article, the table has only the following fields that make sense to us:

Field name Field type Field meaning Other
product_id C (6) Product number  
Prod_name C (40) Product Name  
In_stock N (12,3) Inventory quantity Do not print decimal
On_order N (12,3) Quantity Ordered Do not print decimal
Reorder_at N (12,3) Procurement critical Quantity (equal to or below this quantity should be procured)  
Discontinu L Do you still run this product  

Let's take a look back at the details of the report band, which has five messages to print, as follows:

    1. Product number (PRODUCT_ID)

    2. Product Name (Prod_name)

    3. Inventory Quantity (In_stock)

    4. Ordered Quantity (on_order)

    5. Tips

Each product is listed as a row, and the following logic is used to detect each product information and to determine the print format:

    1. No longer operates this product (discontinu=. F.), the message "Prompt" is empty, and the other four kinds of information on the bank are drawn on the line! (Black font)

    2. Still operate this product (discontinu=. T.) and "when the number of libraries" <= "procurement critical Quantity", displays the "prompt" information for all five kinds of information about the bank in red font.

    3. Still operate this product (discontinu=. T.) and "in the number of libraries" > "Procurement Critical Quantity", the "prompt" information is blank, for all five kinds of information on the bank's black font.

Planning your Web page in FrontPage

Now let's start designing the web! Open FrontPage 2000, create a new Web page, and create a "blank" page in the form of "WYSIWYG" as follows:

If you have research on web design, making the page above may take only a few minutes. The "HTML" of this page is as follows:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "generator" content= "Microsoft FrontPage 4.0" >
<meta name= "ProgId" content= "FrontPage.Editor.Document" >
<title>my-Vfp-html</title>
<style>
<!--
. boe1 {font-family:verdana; font-size:10pt; Margin-left:2}
. boe3 {font-family:verdana; font-size:10pt; text-decoration:line-through; Margin-left:2}
. boe2 {font-family:verdana; font-size:10pt; color: #FF0000; Margin-left:2}
-->
</style>

<body leftmargin= "topmargin=" >

<table border= "1" width= "94%" cellspacing= "0" cellpadding= "0" bordercolor= "#000000" >
<tr>
&LT;TD width= "100%" >
<p style= "Margin-bottom: -10" ><font face= "Verdana" size= "2" ><b>description</b></font ></p>
<p style= "MARGIN-LEFT:3; Margin-right:3 "><font face=" Verdana "size=" 3 "><b>you can use the Printwhen expression to change the FONTST Yles printed based on the values being printed. In Thiscase, the detail-printed in red for those products whose in the-below level. Also, any products
That's have been discontinued are printed in strikeout.</b></font></td>
</tr>
</table>
<p> </p>
<p align= "center" ></p>
<table border= "0" width= "100%" >
<tr>
&LT;TD width= "41%" ><font face= "Verdana" size= "3" ><b>Product</b></font></td>
&LT;TD width= "17%" ><font face= "Verdana" size= "3" ><b>in stock</b></font></td>
&LT;TD width= "18%" ><font face= "Verdana" size= "3" ><b>on order</b></font></td>
&LT;TD width= "24%" ></td>
</tr>
</table>
<table border= "2" width= "100%" bordercolor= "#000000" height= "1" cellspacing= "0" cellpadding= "0" >
<tr>
&LT;TD width= "100%" height= "1" ></td>
</tr>
</table>
<table border= "0" width= "100%" >
<tr>
&LT;TD width= "8%" ></td>
&LT;TD width= "33%" ></td>
&LT;TD width= "17%" ></td>
&LT;TD width= "19%" ></td>
&LT;TD width= "23%" ></td>
</tr>
</table>
</body>

Working with style sheets

This is a Web optimization technology, you can not, but this article will use the example of it!

The point here is that when I make a Web page, I use CSS (style sheet) technology to define three styles in advance, that is, the three formats that data rows are displayed in different situations. The intention is that the data will be repeated in the future when the data page is generated (N times), and if you use a generic tag to format it, those repeated occurrences of the tag will be long and inefficient. Now we define once, and then repeatedly quote, improve efficiency! The following code is about the style sheet we created:

<style>
<!--
. boe1 {font-family:verdana; font-size:10pt; Margin-left:2}
. boe3 {font-family:verdana; font-size:10pt; text-decoration:line-through; Margin-left:2}
. boe2 {font-family:verdana; font-size:10pt; color: #FF0000; Margin-left:2}
-->
</style>

In the example of this article, if you do not use stylesheet technology, the most common row of data is defined as follows:

<tr>
<TD width= "8%" ><p style= "Margin-left:3" ><font face= "Verdana" size= "2" >1</font></td>
<TD width= "33%" ><p style= "Margin-left:3" ><font face= "Verdana" size= "2" >Chai</td>
<TD width= "17%" ><p style= "Margin-left:3" ><font face= "Verdana" size= "2" >39</td>
<TD width= "19%" ><p style= "Margin-left:3" ><font face= "Verdana" size= "2" >0</td>
<TD width= "23%" ></td>
</tr>

If you use style sheet technology, you will do the following:

<tr>
<TD width= "8%" ><p class= "Boe1" >1</font></td>
<TD width= "33%" ><p class= "Boe1" >Chai</td>
<TD width= "17%" ><p class= "Boe1" >39</td>
<TD width= "19%" ><p class= "Boe1" >0</td>
<TD width= "23%" ></td>
</tr>

The greater the number of visible data rows, the more cost-effective use of style sheet technology!

How do you define a style sheet in FrontPage?

Format menu-> style (S) ...-> appears in the Style dialog box-> new (N)-> appears as follows:,

-> Enter the name of the style in the name (selector) In this dialog box, noting that the name is preceded by a dot number, such as:. Boe1.

-> point "Format (O)" for formatting. When you are done, press confirm to save the style. FrontPage will automatically write the style you defined to the file.

Further, in the application we can design a variety of style sheets in advance for users to choose to apply, so that your program will be more perfect!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.