VB计算结果直接导入excel

从网上下个一个vb编的程序(不是源程序),用于计算时它的计算结果不能直接输出导入excel,使之实用性不强。本人对计算机程序编程了解甚少,网络高手众多,希望能帮我解决这个问题。
如果你有兴趣,我的qq:2219968869,我将程序发给你,在此先感谢先。

第1个回答  2012-03-26
Public Sub ExportOut(fpsp As fpSpread, cDl As CommonDialog, m As Form, str As String)
On Error Resume Next

Dim i As Integer
Dim ss As Variant

fpsp.GetText 1, 1, ss
If Len(Trim(ss)) = 0 Then Exit Sub

'选择需要保存的文件
cDl.Filter = "Microsoft Excel文件(*.xls)|*.xls"
cDl.DialogTitle = "选择保存路径"
cDl.FileName = ""
cDl.ShowSave
If cDl.FileName = "" Then Exit Sub
If Dir(cDl.FileName) <> "" Then
If MsgBox("你选择的文件已经存在,是否覆盖该文件?", vbExclamation + vbYesNo) = vbNo Then
Exit Sub
Else
Kill (cDl.FileName)
End If
End If
Dim Titlename As String
Titlename = cDl.FileName

Dim xl As Excel.Application
Dim xlk As Excel.Workbook
Dim xlt As Excel.Worksheet

Set xl = New Excel.Application
Set xl = CreateObject("Excel.Application")
Set xlk = xl.Workbooks.Add
Set xlt = xlk.Worksheets(1)
xl.Visible = False
xlt.Activate
m.Caption = str & "——请稍候,正在导出。。。"

xl.Range(xl.Cells(2, 1), xl.Cells(Val(fpsp.MaxRows + 1), fpsp.MaxCols)).NumberFormatLocal = "@"
Dim po As Integer
For po = 0 To fpsp.MaxRows
For i = 1 To fpsp.MaxCols
fpsp.GetText i, po, ss
xl.Cells(po + 1, i) = ss
Next
Next

xlt.SaveAs Titlename
m.Caption = str & "——已成功导出到“" & Titlename & "”!"
xlk.Close
xl.Quit
Set xlt = Nothing
Set xlk = Nothing
Set xl = Nothing
End Sub
第2个回答  2012-03-26
这要看是什么网格控件以及你怎么赋值的
欢迎追问本回答被提问者采纳
第3个回答  2012-03-26
hh
相似回答
大家正在搜