将.xls文件导入到Access 365中

我有各种.xls文件,我无法在Excel中打开,因为它们太大了。 我一直在尝试将它们导入到Access 365中,但得到错误,即Access无法访问文件中的信息。 今天早上我一直在阅读几个论坛的build议,但唯一的build议是不可行的,因为他们需要打开文件并保存在.xlsx,我不能这样做,因为如上所述,我无法打开文件。 任何意见,将不胜感激。

你怎么能有一个Excel文件,你不能在Excel中打开? 您必须使用Excel来创build文件。 我知道唯一的限制就是你正在使用的机器上的RAM。

你可以尝试下面的脚本?

Sub Import() Dim strPathFile As String, strFile As String, strPath As String Dim strTable As String Dim blnHasFieldNames As Boolean ' Change this next line to True if the first row in EXCEL worksheet ' has field names blnHasFieldNames = False ' Replace C:\Documents\ with the real path to the folder that ' contains the EXCEL files strPath = "C:\Documents\" ' Replace tablename with the real name of the table into which ' the data are to be imported strTable = "tablename" strFile = Dir(strPath & "*.xls") Do While Len(strFile) > 0 strPathFile = strPath & strFile DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _ strTable, strPathFile, blnHasFieldNames ' Uncomment out the next code step if you want to delete the ' EXCEL file after it's been imported ' Kill strPathFile strFile = Dir() Loop End Sub 

如果Access无法处理它,而且我觉得很难相信,那么可以使用SQL Server来完成这项工作。

http://www.accessmvp.com/KDSnell/EXCEL_Import.htm

 Select * into SQLServerTable FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=D:\testing.xlsx;HDR=YES', 'SELECT * FROM [Sheet1$]') 

http://www.ashishblog.com/importexport-excel-xlsx-or-xls-file-into-sql-server/

或者…使用R来完成这个任务。

 library(xlsx) file <- system.file("tests", "test_import.xlsx", package = "xlsx") res <- read.xlsx(file, 1) # read first sheet head(res[, 1:6]) 

http://www.sthda.com/english/wiki/r-xlsx-package-a-quick-start-guide-to-manipulate-excel-files-in-r

如果这些选项都不起作用,我会说Excel文件可能是腐败的,这是一个完全不同的问题。