请问如何在vs2010中用vb创建一个excel文件? 20
3个回答
展开全部
VS 软件太大,我没有安装 ,VB6中是可以的,供参考
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Set objExcel = CreateObject("Excel.Application")
Set objWorkBook = objExcel.Workbooks.Add()
objExcel.Visible = False
Dim objSheet As Excel.Worksheet
Set objSheet = objExcel.Worksheets("sheet1")
objSheet.Cells(1,1) = "姓名" '对单元格赋值
objSheet.Cells(1,2) = Date
objSheet.Cells(1,3) = Time
objWorkBook.SaveAs App.Path & "\a.xls" '保存
objWorkBook.Close
objExcel.Quit
Set objSheet = Nothing
Set objWorkBook = Nothing
Set objExcel = Nothing
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Set objExcel = CreateObject("Excel.Application")
Set objWorkBook = objExcel.Workbooks.Add()
objExcel.Visible = False
Dim objSheet As Excel.Worksheet
Set objSheet = objExcel.Worksheets("sheet1")
objSheet.Cells(1,1) = "姓名" '对单元格赋值
objSheet.Cells(1,2) = Date
objSheet.Cells(1,3) = Time
objWorkBook.SaveAs App.Path & "\a.xls" '保存
objWorkBook.Close
objExcel.Quit
Set objSheet = Nothing
Set objWorkBook = Nothing
Set objExcel = Nothing
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询