2017-04-22 107 views
0

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

回答

1

如何获得无法在Excel中打开的Excel文件?您必须在某个时间使用Excel创建文件。正如我所知,唯一的限制是您正在使用的机器上的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文件可能已损坏,这是一个完全不同的问题。

+0

嗨。感谢上述所有。内存问题似乎是笔记本电脑无法应对的问题。这些文件是从Oracle数据库下载的系统,因此尚未由用户创建。但是,我使用访问来处理文件的问题似乎与文件是.xls的事实有关,并且访问表示它无法读取数据。 –