Using ASP to transfer HTML format to Excel (2)

Source: Internet
Author: User
Create an HTML table
First set up the ASP home page, add the home page to the Visual InterDev project, the file name is contenttype.asp, as shown in Figure A
。 Then add the code shown by code A to the home page, and the first line of code converts the MIME type of the page involved to Excel MIME type. The following lines of code will start the component we established earlier to get the data for the Ador record area. The code, as shown in Listinga, loops through the record area and creates an HTML table that includes records for each row in the employee table.


Code A:code for adding new ASP page to Visual InterDev Project
<%@ Language=vbscript%>

<%response.contenttype = "Application/vnd.ms-excel"%>

<%
Dim Objemployee, RS

Set Objemployee=server. CreateObject ("Empreport.employee")

Set rs = Objemployee.getemployee ()

' Draw a Table

%>
<TABLE>
<TR>
<td><strong><font face= "" Size=4>employee
Report</font></strong></td>
</TR>
<TR>
<td>employee id</td>
<td>first name</td>
<td>last name</td>
<TD>Title</TD>
</TR>
<%
Do as not rs.eof
%>
<TR>
<TD>
<%=rs ("EmployeeId")%></td>
<TD>
<%=rs ("LastName")%></td>
<TD>
<%=rs ("FirstName")%></td>
<TD>
<%=rs ("Title")%></td>
</TR>
<%
Rs.movenext
Loop
%></table>

When you have finished entering your code, save and browse the home page. The home page is like Figure B. Note that all the rows in the spreadsheet do not have any formatting. When we use the Excel VBA component to create a work table, we can use VBA to adjust the table. However, it is more difficult to format a table normally using HTML, unless you can easily display and read the data about the HTML table. We can do this with ASP home technology, and we can achieve all the features currently supported by Microsoft Excel, including the sum feature. It should be noted that the work table created using HTML does not include some standard notation, such as <HTML> and <BODY>. When we create an HTML table that swaps data with an Excel worksheet, try not to use the <HTML>,<BODY>,<HEAD> notation in the ASP home page, because Excel worksheets usually don't have the right markings.




Related Article

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.