VB开发——复制Excell表格
'假设定义的记录名为myres
Dim myexcel As New Excel.Application
Dim mybook As New Excel.Workbook
Dim mysheet As New Excel.Worksheet
Set mybook = myexcel.Workbooks.Add '添加一个新的BOOK
Set mysheet = mybook.Worksheets.Add '添加一个新的SHEET
myexcel.visible=true
mysheet.Cells.CopyFromRecordset myres
mybook.SaveAs (m_ExcelName) '保存文件
也可以:
Dim strSource As String
Dim strDestination As String
strSource = App.Path & "/Excels/RegisterFee.xls"
'RegisterFee.xls就是一个模版文件
strDestination = App.Path & "/Excels/Temp.xls"
FileCopy strSource, strDestination
千万不要试图使用循环语句,来复制每个单元格,那样的效率是在是太低了,呵呵!