小弟想知道Excel.Application的部分属性和方法
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
1.xlsheer 如何保存到我指定的路径,如何修改名字
请高手写下调用什么方法(包括的方法的参数)
最好能有哪位告诉给点Excel.Application的资料
小弟我先谢过
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
1.xlsheer 如何保存到我指定的路径,如何修改名字
请高手写下调用什么方法(包括的方法的参数)
最好能有哪位告诉给点Excel.Application的资料
小弟我先谢过
dim oExcel as new excel.application
oExcel. 输入到 . 这个地方时,vb会自动提示你这个对象的属性、方法的。用 createobject 建立的对象,vb不能自动提示。
exlapp.ActiveWorkbook.Close False
exlapp.Quit
Private _openBook As Excel.Workbook
Private _openSheet As Excel.Worksheet
Private _fileName As String Public Sub New(ByVal fileName As String)
Me._openExcel = CType(CreateObject("Excel.Application"), Excel.Application)
Me._openBook = CType(_openExcel.Workbooks.Add, Excel.Workbook)
Me._openSheet = CType(_openBook.Worksheets(1), Excel.Worksheet)
Me._fileName = fileName End Sub
Public Sub SaveAndClose() Me._openBook.SaveAs(Me._fileName)
Me._openBook.Close()
Me._openExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(Me._openSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(Me._openBook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(Me._openExcel)
System.GC.Collect()
End Sub
end class
WorkTable.SaveAs Filename:=App.Path + "\Excel格式病历\ " & gName & "_" & gNumber ', FileFormat:=xlHtml 用这种方法就可以保存为HTM格式用SaveAs 方法就可以做到了。
我的做法是先进行保存然后再显示出来,这样还要控制文本的真实性,一但有人改过了,又不想要了,会很麻烦的。 我给了你两种保存方法,希望能对你帮助!