How do I open a .xls file in ArcMap without Office installed? - excel

I am trying to open and copy xls documents in the Catalog window of ArcMap 10.6.1.
Everytime I try to expand the table I get this error message:
"Failed to connect to database. General function failure.
The external table doesn't have the expected format." (translated from German)
I've tried installing (then updating) "2007 Office System Driver: Data Connectivity Components" and "Microsoft Access Database Engine 2010 Redistributable" but that didn't help.
I'm running ArcGIS 10.6.1 on Windows Server 2012 R2 without an Office installation.
Interestinlgy, on another machine, running ArcGIS 10.5.1 with the same OS and no Office, it works fine!

Try this which can help you read and use data from a .xls using arcpy window:
import arcpy
import xlrd
inputExcel = xlrd.open_workbook("C:\Users\username\In_excel.xls")
sheetNames = inputExcel.sheet_names()
excelSheet = inputExcel.sheet_by_name(sheetNames[0])
for x in range (0, excelSheet.nrows):
for y in range (0 excelSheet.ncols):
cellValue = excelSheet.cell_value(x, y)
print (cellValue)

Related

Excel Macro VBA CopyFromRecordSet to retrieve MicroFocus ALM data gives Class doesn't support Automation (Error 430)

I am trying to run a SQL query through Excel VBA to extract MicroFocus ALM data to excel spreadsheet but I am hitting the "Class does not support Automation or does not support expected Interface" error, Error Code 430.
I have enabled the library "Microsoft ActiveX Data Object Recordset 2.8 Library" in the References. After searching for forums I found a suggestion to add the msado15.dll using the below command.
Regsvr32.exe "C:\Program Files\Common Files\System\ado\msado15.dll"
I tried that too, but still the same issue. Below is the code I use and I hit error in the last line where I try to load data to "test" tab. When I add watch on the RecSet variable, I do see that RecSet is loaded with 70 ColCount and 1358 RecordCount after the SQL is executed, but in the last step to load the data to excel I am facing problem. Any help on this is appreciated. Thanks
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx qcURL
QCConnection.ConnectProjectEx sDomain, sProject, sUser, sPass
Application.StatusBar = "Logged in ALM as " & sUser
Set com = QCConnection.Command
Sql = "select * FROM BUG"
com.CommandText = Sql
Set RecSet = com.Execute
ThisWorkbook.Sheets("test").Range("A1").CopyFromRecordset RecSet 'Error 430
Install ALM Client or ALM Connectivity Tool from your ALM server:
http://almserver:8080/qcbin/addins.html

Package executed in Visual Studio cancels without helpful error

I am following a Udemy Course Learn ETL using SSIS. The first simple task is to transfer data from an excel file to a database.
The only change I have made is I am trying to transfer to a PostgreSQL server instead of a Microsoft SQL Server. I therefore had to install SSDT for Visual Studio first, and get the ODBC driver necessary to create a ODBC Destination for the package.
All well so far, but then when I try and run the package I just get:
SSIS package "Visual Studio 2017\Projects\Excel_SQL\Excel_SQL\Package.dtsx" starting.
Information: 0x4004300A at Excel to SQL, SSIS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at Excel to SQL, SSIS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at Excel to SQL, SSIS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Excel to SQL, SSIS.Pipeline: Pre-Execute phase is beginning.
Information: 0x4004300C at Excel to SQL, SSIS.Pipeline: Execute phase is beginning.
SSIS package "Visual Studio 2017\Projects\Excel_SQL\Excel_SQL\Package.dtsx" finished: Canceled.
The program '[14368] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).
No data transfers over. The excel file is very simple, excel 97-2003 as the connection expects, contains 2 columns only, rollnumber and marks, rollnumber has 11 rows of data going 1 to 11, and then some random marks in the marks column.
My database on Postgres is set up with these 2 columns, as numeric types.
I really cannot figure out what is going wrong.
I have seen some similar questions on stack overflow, but that was around the file type not being correct:
SSIS Package Cancels instantly on Debug
I don't think that's my issue.
Can anyone please advise?
Thank you.
I think the situation is not clear, but there are many suggestions that you can follow:
(1) Try to run the package in 32-bit
The issue may be caused if the package is trying to run in 64-bit mode and you don't have installed the relevant references, try to execute the package in 32-bit mode:
Package Properties >> Debugging >> Run64BitRuntime = false
How to execute a 32 bit SSIS package in a 64bit package?
(2) AccessDatabaseEngine is not installed
The issue may be caused if the Office connectivity components for microsoft Excel are missing, check that you have installed them:
Microsoft Access Database Engine 2010 Redistributable
Microsoft Access Database Engine 2016 Redistributable
(3) Make sure you have followed the appropriate steps to create ODBC Destination
You can follow this article in order to create a package that import data to postgres, check that all steps are done correctly:
SSIS WITH POSTGRESQL : CONNECT TO POSTGRESQL WITH SSIS COMPONENTS
(4) Doing some workarounds
In order to specify the error source, try to replace the Postgres destination with a Flat File Destination, if the package is executed successfully then the problem is with the ODBC Destination, also try to replace the excel source with FLat File Source, if the package is executed successfully then the problem is with the Excel Source.
If you are new to SSIS, som articles can help:
Simple SSIS: Importing Data from Flat Text Files
Export Data from SQL Server to Flat File in SSIS Example
Using SSIS to Export Data to Flat Files
(5) Try to Use SQL Import Export Wizard
If you have SQL Server Installed, try to use the Excel Import Export wizard to create and execute the package:
Import and Export Data with the SQL Server Import and Export Wizard
Connect to a PostgreSQL Data Source (SQL Server Import and Export Wizard)
How to export data from SQL Server to a Flat file
So, in this case it was that I just had to move the (Source) excel file out to my E:\ drive. Perhaps the path it was in was too long? Only 3 folders in from E:\ but...it worked.
Can anyone explain why that was the issue? Nothing pointed to that from the error messages.

SSIS Dynamically Import Excel Files

So I created a ForEach loop and a data flow task to write from Excel to SQL DB. All works fine with the Excel source hard coded. As soon as I change the connection string to use the file path variable as a data source, I get this error:
[Excel Source 1] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager 1" failed with error code 0xC0202009.
I print the file path in a message box before executing the data flow so I know that the variable is working.
Naturally I browsed tons of answers and tutorials, but nothing. Here's what I tried:
Changing the data source on the connection string
Using the ExcelFilePath expression instead of the connection string
Changing the Excel file name in the connection manager properties
Ran the package in 32 bits
Set delayed validation to True in all data flow tasks and connection manager
Deleting and creating a new connection manager
Combinations of the above, lots of trial an error
I'm using Visual Studio 2013.
I'd appreciate your help as I've been plucking my hair all afternoon with this :)
I never got this to work, so I imported the Excel files to the DB using SQL:
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Test\Excel_Data.xlsx;', 'SELECT * FROM [Sheet1$]')
https://www.sqlshack.com/query-excel-data-using-sql-server-linked-servers/

Use VBA to pull SQL CE 4.0 data to latest excel, showing 'method open of object connection failed' error

I was trying to use excel vba to pull some data from a sql ce .sdf file to excel, here are the codes I have used, which comes from Eric's sample post.
Set Cnxn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;" & _
"Data Source=C:\Northwind.sdf;"
Cnxn.Open strCnxn
I have checked Microsoft ADO 6.1 Library as reference, but getting a error message saying:
Method 'Open' of object '_Connection' failed.
Anyone know how to solve this issue? Thanks

Reading excel file (.csv) using ODBC driver in Qt

I have a csv file that I'd like to parse in Qt. I'd like to use the sql plugin, but I'm not sure how to get things set up. I currently am unable to open the .csvfile from my Qt app--I have to manually open it then start my app in hopes to query from it.
If the file I'm trying to read isn't manually opened before I begin my app, I get the following driver error:
[Microsoft][ODBC Excel Driver] External table is not in the expected format.
[Microsoft][ODBC Excel Driver] General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1ae0 Thread 0x1f2c DBC 0x4c52a4 Excel.' QODBC3: Unable to connect.
Here's my setup...
Qt Creator Build/Version:
I am working in Qt 5.3 which I did not build from source--I downloaded the installer.
I have configured a few debugging kits, but the one i'm using currently uses the MSVC 2012 openGL 32 bit compiler (which I've got set to default).
I have both Visual Studio 2012 AND 2010 on my machine, which is 64bit.
I didn't have to make the sql drivers, they came installed already (available drivers: () ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7"))
My .pro file hooks to the sql plugin:
QT += core gui network sql
And I've got the following includes:
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
This is my code that establishes an Excel database connection and attempts a query:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
QString pathString = QString("C:\\MY_FILES\\test_work\\Xena\\Xena2544-2G\\Reports\\asdf_SN1_RFC2544_7_port_verify.csv");
db.setDatabaseName("DRIVER={Microsoft Excel Driver (*.xls)};DBQ=" + pathString );
if (!db.open())
{
QSqlError er = db.lastError();
QMessageBox::information(0, "Error", er.text());
}
if(db.open())
{
QSqlQuery query("select * from [" + QString("asdf_SN1_RFC2544_7_port_verify") + "$B13]"); //NEVER GETS HERE UNLESS i ALREADY MANUALLY OPENED THE FILE BEFORE RUNNING CODE.
QString process1Result = query.value(0).toString();
ui->verifyUnit1Status_lb->setText(process1Result);
}
File Permissions
- Full control
- modify
- read& execute
- read
- write
I'd really like to get this feature going. I would assume the error is in the connection string, but at this point I've tried for a couple hours with no success.
Thank you in advance.

Resources