如何从传统的ASP输出的Excel * .xls文件 [英] How to output an Excel *.xls file from classic ASP

查看:191
本文介绍了如何从传统的ASP输出的Excel * .xls文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数字,我需要输出为Excel文件生成的HTML表格。该网站是在传统的ASP codded。这可能吗?难道不知何故通过使用开放式办公库做?

I have a number of generated html tables that I need to output as an Excel file. The site is codded in classic ASP. Is this possible? Could it be done by somehow using the Open Office libraries?


编辑:到目前为止,我已经尝试了一些建议,但似乎失败。理想情况下,我希望用户能够点击一个链接,将开始一个.xls文件的下载。这code:

Thus far, I have tried some of the suggestions, but it seems to fail. Ideally, I want the user to be able to click a link that will begin the download of a .xls file. This code:

<%@ Language=VBScript %>
<%  option explicit

Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader "content-disposition", " filename=excelTest.xls"
%>
<table>
    <tr>
        <th>Test Col 1</th>
        <th>Test Col 2</th>
        <th>Test Col 3</th>
        <th colspan="2">Test Col 4</th>
        <th>Test Col 6</th>
        <th>Test Col 7</th>
    </tr>
    <tr>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
        <td>Data</td>
    </tr>
</table>

似乎IE7时,用于获取网页失败。 IE浏览器说,它不能下载excelTest.asp和请求的站点是不可用或无法找到。

seems to fail when IE7 is used to get the page. IE says that it "cannot download excelTest.asp" and that "The requested site is either unavailable or cannot be found."

推荐答案

它的AddHeader不是AppendHeader。

It's AddHeader, not AppendHeader.

<%@ Language=VBScript %>
<%  Option Explicit

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=excelTest.xls"
%>
<table>
    <tr>
        <td>Test</td>
    </tr>
</table>

更新:
我已经写了一个博客张贴有关如何生成Excel文件在ASP经典的。它包含code的相当有用一块来生成XLS和CSV文件。

Update: I've written a blog post about how to generate Excel files in ASP Classic. It contains a rather useful piece of code to generate both xls and csv files.

这篇关于如何从传统的ASP输出的Excel * .xls文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆