简体   繁体   English

无法从新上传的Excel文件中读取数据

[英]Cannot read data from newly uploaded Excel file

I'm working on a system where the users need to be able to upload an excel file to the server, then the system needs to process the excel file to load data into the XMPie uProduce system. 我正在一个系统上,用户需要能够将excel文件上传到服务器,然后系统需要处理excel文件以将数据加载到XMPie uProduce系统中。

I already have it working to load CSV files into the system. 我已经可以将CSV文件加载到系统中了。 I can confirm that the excel files have been uploaded to the server successfully. 我可以确认excel文件已成功上传到服务器。 However, when my program then tries to access the excel file in order to read the data, it gets this error: 但是,当我的程序然后尝试访问excel文件以读取数据时,会出现以下错误:

The Microsoft Jet database engine could not find the object 'Sheet1'. Make sure the object exists and that you spell its name and the path name correctly.

I am setting the filter as: 我将过滤器设置为:

select * from [Sheet1]

I have also tried it as: 我也尝试过:

select * from [filename.xls]

Neither have worked. 都没有工作。 Does anyone have any suggestions what the SQL filter should be for pulling data from a database? 有人对SQL过滤器从数据库中提取数据应该有什么建议吗?

Try this.. 尝试这个..

Writing an Excel query is as similar as writing a query in any other traditional data storage like SQL Server, Oracle, etc. However there are a few differences. 编写Excel查询与在任何其他传统数据存储(如SQL Server,Oracle等)中编写查询相似。但是有一些区别。 First, you have to specify your sheet name instead of your table name. 首先,您必须指定工作表名称而不是表名称。 Next, you have to give starting and end cell references. 接下来,您必须提供开始和结束单元格引用。 Watch my following code carefully: 仔细观看以下代码:

SELECT * FROM [users$A1:F500] 选择*从[users $ A1:F500]

Here users is the spread sheet name. 这里的用户是电子表格的名称。

When specifying Excel sheet names in an SQL query via ADO or similar, you have to put a $ symbol at the end of the sheet name. 通过ADO或类似方法在SQL查询中指定Excel工作表名称时,必须在工作表名称的末尾添加$符号。 Try: 尝试:

SELECT * FROM [Sheet1$]

More info here 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM