正在从 Excel 中提取数据到 Access 数据库
Extracting data from Excel to Access Database
目前有一个带字段的 Word 格式的标准公司表格(可以使用不同的技术)。
如何将这些字段中的数据提取到我的 Access 数据库中?
我也愿意听取关于哪种技术更适合我的要求的建议,要求是:
- 需要将文件发送给客户并将填写的信息添加到数据库中
- 能够从数据库中检索信息并将其表示为
将该表格翻译成 Excel。使用功能区 "External Data" 选项卡下的 "Collect Data" 从客户那里收集数据。要将数据从 Access 提取到电子表格中,请执行以下操作。使用 Excel 电子表格作为表格。然后创建一个带有以下事件的命令按钮:
'"cmdbtn1" is the name you assign your command button.
Private Sub cmdbtn1_Click()
Dim appExcel As Excel.Application
Dim wbook As Excel.Workbook
Dim wsheet As Excel.Worksheet
Set appExcel = New Excel.Application
appExcel.Visible = True
Set wbook = appExcel.Workbooks.Open("C:\PathToYourDocument\YourSpreadsheet.xlsx")
'"YourSpreadsheet" is the name of the actual sheet in your workbook.
Set wsheet = wbook.Worksheets("YourSpreadsheet")
With wsheet
'The numbers next to ".Cells(" correspond to locations on your spreadsheet. A1=(1, 1), B1=(1,2), A2=(2, 1)
.Cells(10, 1).Value = txtThing1
.Cells(10, 2).Value = txtThing2
'This is how you combine multiple cell in excel into one Access field.
.Cells(10, 3).Value = txtThing3 + " " + txtThing4 + " " + txtThing5 + " " + Thing5
End With
End Sub
目前有一个带字段的 Word 格式的标准公司表格(可以使用不同的技术)。
如何将这些字段中的数据提取到我的 Access 数据库中?
我也愿意听取关于哪种技术更适合我的要求的建议,要求是:
- 需要将文件发送给客户并将填写的信息添加到数据库中
- 能够从数据库中检索信息并将其表示为
将该表格翻译成 Excel。使用功能区 "External Data" 选项卡下的 "Collect Data" 从客户那里收集数据。要将数据从 Access 提取到电子表格中,请执行以下操作。使用 Excel 电子表格作为表格。然后创建一个带有以下事件的命令按钮:
'"cmdbtn1" is the name you assign your command button.
Private Sub cmdbtn1_Click()
Dim appExcel As Excel.Application
Dim wbook As Excel.Workbook
Dim wsheet As Excel.Worksheet
Set appExcel = New Excel.Application
appExcel.Visible = True
Set wbook = appExcel.Workbooks.Open("C:\PathToYourDocument\YourSpreadsheet.xlsx")
'"YourSpreadsheet" is the name of the actual sheet in your workbook.
Set wsheet = wbook.Worksheets("YourSpreadsheet")
With wsheet
'The numbers next to ".Cells(" correspond to locations on your spreadsheet. A1=(1, 1), B1=(1,2), A2=(2, 1)
.Cells(10, 1).Value = txtThing1
.Cells(10, 2).Value = txtThing2
'This is how you combine multiple cell in excel into one Access field.
.Cells(10, 3).Value = txtThing3 + " " + txtThing4 + " " + txtThing5 + " " + Thing5
End With
End Sub