创建excel电子表格 [英] create excel spreadsheet

查看:32
本文介绍了创建excel电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以使用 VBScript 创建 Excel 电子表格?我可以使用 FileSystemObject 创建一个文本文件并使用我想要的任何扩展名,但是当我尝试下载它时,它给了我在 excel 中打开选项,然后出现一条消息,说明它采用不同的格式,这就是我想避免:

Is there any way to create an excel spreadsheets using VBScript? I can create a text file using a FileSystemObject and use any extension I want, but when I try and download this and it gives me the open in excel option a message then appears stating that it is in a different format, and that is what I want to avoid:

set fs=Server.CreateObject("Scripting.FileSystemObject")
set tfile=fs.CreateTextFile(Server.MapPath("xls/streamtest.xls"),true,false)

我知道这是以 ASCII 格式将文本推送到文件中.

I know this is pushing text into the file in ASCII format.

我可以使用某事"字符序列、特定格式来解决所有这些问题吗?

Is there 'something' character sequence, specific formatting that I can use to get around all of this?

谢谢

推荐答案

最好,最快的方法是生成一个Excel xml文件,不使用服务器上的Excel.application,确实不推荐.您唯一不能做的功能是插入图片.

The best and fastest way, without using Excel.application on the server, which is really not recommended, is to generate an Excel Xml file. The only feature you won't be able to do is insert a picture.

与使用 html 表格不同,您将能够在 excel 中支持原生数据(如日期),并且您将能够格式化、插入公式……

Unlike using html table, you'll be able to support native data in excel (like date), and you'll be able to format, insert formula, ...

将您的 Excel 保存为 Excel XML 并查看生成的 XML 文件.这有点棘手,但效果很好.

Save your excel as Excel XML and see the generate XML file. This is little bit tricky, but works very well.

这篇关于创建excel电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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