vb将textbox导出到excel
答案:3 悬赏:40 手机版
解决时间 2021-02-20 08:22
- 提问者网友:回忆在搜索
- 2021-02-19 16:20
我用的是vb6textbox中有如下格式的内容班 名 号 分数 详细1 a 1 10 A D C1 b 2 15 D A C以空格为换行标志,然后导出到excel中
最佳答案
- 五星知识达人网友:笑迎怀羞
- 2021-02-19 17:05
Dim app As New Excel.Application'定义app为Excel应用程序
Dim book As Excel.Workbook'定义book为的工作簿
Dim sheet As Excel.Worksheet’定义sheet为的工作表
Private Sub Command1_Click()'点击command1按钮实现导入
Set book = app.Workbooks.Add'新建book
Set sheet = book.Sheets(1)'新建sheets(1)
sheet.Range("A1").Value = Text1.Text'sheets(1)中A1赋值为text1内容
sheet.Range("B1").Value = Text2.Text'sheets(1)中B1赋值为text2内容
End Sub
Dim book As Excel.Workbook'定义book为的工作簿
Dim sheet As Excel.Worksheet’定义sheet为的工作表
Private Sub Command1_Click()'点击command1按钮实现导入
Set book = app.Workbooks.Add'新建book
Set sheet = book.Sheets(1)'新建sheets(1)
sheet.Range("A1").Value = Text1.Text'sheets(1)中A1赋值为text1内容
sheet.Range("B1").Value = Text2.Text'sheets(1)中B1赋值为text2内容
End Sub
全部回答
- 1楼网友:一叶十三刺
- 2021-02-19 18:39
分割函数 然后 x=split(s," ") ,s为一条记录 Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1) for i=0 to ubound(x) xlSheet(1,i+1)=x(i) next
xlApp.ActiveWorkbook.SaveAs "D:\1.xls" xlApp.Visible = False
xlBook.Close (True) '关闭工作簿
- 2楼网友:轮獄道
- 2021-02-19 18:01
分割函数 然后 x=split(s," ") ,s为一条记录 Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1) for i=0 to ubound(x) xlSheet(1,i+1)=x(i) next
xlApp.ActiveWorkbook.SaveAs "D:\1.xls" xlApp.Visible = False
xlBook.Close (True) '关闭工作簿
xlApp.Quit '结束EXCEL对象
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing '释放xlApp对象
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯