ExcelWord Format DisplayExport Data

zhaozj2021-02-16  56

[Operating environment]: DWMX WIN2000ADV Access2000

[Plug-in download]: MIME TYPE-EXCEL MIME TYPE-Word Plugin Source: http://www.assontriver.com

[Principle]: The ContentType property of the Response object

The CONTENTTYPE attribute of the Response object can be used to set the web server entry to the client's HTTP file type. In general, most web-http file formats are "text / html", so if you don't have special specified, the ASP is Will be the default value as "text / html". The ContentType attribute syntax of the Response object is as follows:

Response.contentType = ContentType

Generally, ContentType is a string of "Type / Sub Type", and HTTP contains considerable types of file types to give a common file type:

<% Response.contentType = "text / html"%>

<% Response.contenttype = "image / jpeg"%>

<% Response.contentType = "image / gif"%>

<% Response.contentType = "Application / X-CDF"%>

The above is a common contentType type, and this tutorial is used in the following two types:

<% Respternse.contenttype = "Application / VND.MS-Excel"%>

<% Response.contentType = "Application / Msword"%>

[Tutorial] Use the plug-in to implement the browser to display or export data in the database, of course, you can also write the code directly to the page, pay attention to the location of this line of code. Location must be Before, it is best to start the page:

1. According to the "Book" as shown in Figure 1:

figure 1

Enter some data for test (Figure 2).

figure 2

2. Run DWMX, establish a test site, create a link "CNBook" (Figure 3).

image 3

3. Create a blank file Excel.asp, create a recordset "RE" as shown in Figure 4's SQL statement

Figure 4

4. Object Panel -> Applications -> Dynamic Forms, inserted into dynamically displayed data as shown in Figure 5.

Figure 5

After clicking the OK button, the page is shown in Figure 6:

Figure 6

5. Apply MIME TYPE-EXCEL server behavior. Location: Server Behaviors-> Assonet River-> Mime Type-Excel (Figure 7)

Figure 7

At this point, the server behavior list shown in Figure 8 will appear in the Server Behavior Settings panel, and the red line box is the MIME TYPE-Excel server behavior we add.

Figure 8

6. Run Excel.asp in the browser, the page will be prompted directly in the browser or download (Figure 9), here we choose to open in the browser.

Figure 9

7.ok! We will see Figure 10 in the browser:

Figure 10

8. Repeat steps 3-7, create a new blank page word.asp, different in step 5, apply the MIME TYPE-WORD "behavior" MIME TYPE-WORD ". Run Word.asp and select Directly, as shown in Figure 11:

Figure 11

转载请注明原文地址:https://www.9cbs.com/read-20865.html

New Post(0)