📄 subject_66476.htm
字号:
<p>
序号:66476 发表者:mwh 发表日期:2003-12-24 17:23:00
<br>主题:如何编写Excel程序文件
<br>内容: 我欲编一个程序,从文本文件中读出数据后按要求写入Excel文件,但我从来没有这方面的经验,请各位大侠教教小弟应如何在程序中对Excel文件进行操作。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:wafer 回复日期:2003-12-24 17:33:54
<br>内容:可以利用VBScript。<BR><BR>下面是一段将Excel文件转换成txt文件的代码:<BR><BR><BR>Option Explicit<BR><BR>Const ConvertTool = "Convert.xls"<BR>Const ConvertFunc = "Convert.xls!ConvertAll"<BR><BR>'Main<BR>' or<BR>Convert "Data", ".\Data"<BR><BR><BR>Sub Usage()<BR> Dim msg<BR> msg = "Usage:" & Chr(13)<BR> msg = msg & "Convert <InputFolder> [<OutputFolder>]" & Chr(13) <BR> msg = msg & "Convert all Excel files in <InputFolder>, and save text files into <OutputFolder>" & Chr(13) <BR> msg = msg & "Default <OutputFolder> = <InputFolder>"<BR> MsgBox msg<BR>End Sub<BR><BR>Sub Main()<BR> Dim SrcFolder, DstFolder<BR> If WScript.Arguments.Count > 0 Then<BR> SrcFolder = WScript.Arguments(0)<BR> If WScript.Arguments.Count > 1 Then<BR> DstFolder = WScript.Arguments(1)<BR> Else<BR> DstFolder = SrcFolder<BR> End If<BR> Else<BR> Usage<BR> Exit Sub<BR> End If<BR><BR> Convert SrcFolder, DstFolder<BR>End Sub<BR><BR>Sub Convert(SrcFolder, DstFolder)<BR> SrcFolder = AbsPath(SrcFolder)<BR> DstFolder = AbsPath(DstFolder)<BR> On Error Resume Next<BR> Dim xlApp<BR> Set xlApp = CreateObject("Excel.Application")<BR> xlApp.Workbooks.Open GetCurrentPath() & ConvertTool<BR> xlApp.Run ConvertFunc, CStr(SrcFolder), CStr(DstFolder)<BR> xlApp.Quit<BR>End Sub<BR><BR>Function AbsPath(path)<BR> If Mid(path, 1, 1) = "\" Or Mid(path, 2, 1) = ":" Then<BR> AbsPath = path<BR> Exit Function<BR> End If<BR> AbsPath = GetCurrentPath() & path<BR>End Function<BR><BR>Function GetCurrentPath()<BR> Dim path, pos<BR> path = WScript.ScriptFullName<BR> pos = InStrRev(path, "\")<BR> GetCurrentPath = Left(path, pos)<BR>End Function<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:michael 回复日期:2003-12-24 18:04:52
<br>内容: 用DAO编程使用微软Data Jet数据引擎向xls里写数据。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:mwh 回复日期:2003-12-25 10:01:53
<br>内容:应如何使用data jet引擎,能否更详细说明,谢谢
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -