创建EXCEL US preadsheet [英] create excel spreadsheet

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

问题描述

有没有办法使用VBScript创建一个Excel US preadsheets?我可以使用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 US preadsheet
你应该能够在服务器上使用的CreateObject(Excel.Application)如果安装了Office(至少Excel)中。

I answered this on a another question. correct formatting for excel spreadsheet You should be able to use CreateObject("Excel.Application") on your server if office (at least Excel) is installed.

Xls中(以及其他类型的Excel 2007/2010是,你不能很容易地创建这样的二进制fiels,你需要使用COM对象创建和操纵它们。在这里,从脚本专家一个例子<一个href=\"http://blogs.technet.com/b/heyscriptingguy/archive/2005/01/31/how-can-i-make-changes-to-and-then-re-save-an-existing-excel-s$p$padsheet.aspx\" rel=\"nofollow\">http://blogs.technet.com/b/heyscriptingguy/archive/2005/01/31/how-can-i-make-changes-to-and-then-re-save-an-existing-excel-s$p$padsheet.aspx

Xls (and the other types of Excel 2007/2010 are binary fiels that you can not easily create like that, you need to use Com objects to create and manipulate them. Here an example from the scripting guys http://blogs.technet.com/b/heyscriptingguy/archive/2005/01/31/how-can-i-make-changes-to-and-then-re-save-an-existing-excel-spreadsheet.aspx

Set objExcel = CreateObject("Excel.Application") 
objExcel.Visible = True 
objExcel.DisplayAlerts = FALSE 

Set objWorkbook = objExcel.Workbooks.Add 
Set objWorksheet = objWorkbook.Worksheets(1) 

objWorksheet.Cells(1, 1).Value = Now 
objWorkbook.SaveAs("C:\Scripts\Test.xls") 
objExcel.Quit 

请参见 http://msdn.microsoft。 COM / EN-US /库/ aa223697(v = office.11​​)的.aspx 获得的VBA函数的列表,你可以使用

see http://msdn.microsoft.com/en-us/library/aa223697(v=office.11).aspx for a list of vba functions you can use

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

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