xlsm into sql server - sql

I have an xlsm file with macros that enable data collection from OLE DB source. I just need to make an import package with it in sql server. But when I'm trying to use import/export wizard or ssis-it shows that it can not deal with .xlsm extentions.
Is there any way to deal with it?

follow this :
1-Create an Excel Connection Manager to refer to ANY other spreadsheet with a "valid" XLS or XLSX extension. (You don't have to save your XLSM file "as" an XLSX.)
2-Select the Excel Connection Manager in your Connection Managers pane.
3-Open the Properties Window (F4).
4-Change the "Server Name" property to the full pathname of your XLSM file.
note: check the file should not be in read only mode

Had the same issue (SQL Server 2008 R2), Rahul's solution worked for me, but I just want to add a couple of things:
Select Excel 2007 in Excel version when creating Excel Connection.
Use SQL Command as Data access mode when editing the Excel Source. Visual Studio crashed for me every time I was trying to use Table or view.

Related

Use Excel VBA to change Powerpivot connection to csv file

How can I use vba to modify a Powerpivot connection to a csv file? I have an Excel workbook with a Powerpivot model that connects to a csv file. In the Powerpivot window, I can navigate to the Home->Existing Connections and edit the file path as desired. I can't get close to editing this in vba.
I found this link on parameterizing Powerpivot connections.
Unfortunately, I couldn't figure out how to modify to apply to csv file connection rather than database connection.
An alternate approach is described on this page. This approach creates a connection to the data in Excel itself. The connection is then available in Powerpivot. It is critical to not create the connection in Powerpivot bc the author says connections created in Powerpivot cannot be modified by vba.
I can create this connection manually through the
Data->Get External Data->From Text menu option.
I can create the same connection in vba using "Workbooks("myWorkbook.xlsm").Connections.AddFromFile "data.csv". I can manually edit this connection in the Data->Connections->Connections dialog. However, when I try to set this in vba using the WorkbookConnections.TextConnection property, vba says "Object doesn't support this property or method".
The above link focuses on database connections rather than csv file connections. However, it seems possible to set up the csv file with an
Microsoft ACE OLEDB 12.0 connection, but I can't quite grasp it.
There are similar questions on SO that address vba modifying pivot sources (like here:Changing pivot table external data source path with Excel macro).
However, I don't want to bring the data into a table in Excel, I want to connect to it so I can work with it in Powerpivot.
I could probably do this with Power Query, but since I already have the csv in the desired format, I'd rather not have to introduce this additional step.
I'm using Excel 2013 64 bit on Windows 7. Thank you for your help.
I've been playing around with something similar. Haven't succeeded yet, but maybe we can figure it out together...
One thing I've noticed is that it looks like these connections to CSV files aren't actually TextConnections like you'd expect, but rather OLEDBConnections.
EDIT: According to https://goo.gl/x17Nuj, it's just not possible:
Once you modify the connection inside PowerPivot, the link between the Excel and the PowerPivot connections is broken. In fact, you can no longer modify the connection properties in Excel and, if you want to load another table, then you have to use the PowerPivot add-in. Needing to use the add-in means that the option of modifying the connection is no longer available in VBA Because (as you have seen) there is no way to modify the PowerPivot connections using VBA.
(Emphasis is mine)
I was able to modify the file location by setting up the csv file connection as a Microsoft.ACE.OLEDB.12.0 connection. It's actually labelled "Microsoft Office 12.0 Access Database Engine OLE DB Provider" in the Data Connection Wizard. This link helped me figure it out. You need to have "Microsoft ActiveX Data Objects 6.1" added as a reference. Once the connection was created manually, here's the code I used to modify the connection:
Sub editConnection()
With ActiveWorkbook.Connections("myConnectionName").OLEDBConnection
.Connection = "OLEDB;Provider= Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=\\something.com\shared\myDepartment\newDirectory; " & _
"Mode=Read;Extended Properties = ""Text;HDR=Yes;FMT=Delimited;"""
End With
ActiveWorkbook.Connections("myConnectionName").Refresh
End Sub
I didn't figure out how to modify the filename. This also forces the table name in PowerPivot to be the name of the csv file. You can't edit that without breaking the connection.

Excel Services Sharepoint 2010 removes macros from xlsm file

I am using Excel Services in Sharepoint 2010 to inject some data into an Excel xlsm file. This is working fine.
I know that macros will not run on the Sharepoint server, but I want users to be able to download the full workbook after the data injection and have the macros enabled in the full workbook. But, it seems that when Excel Services injects the data, the workbook is always saved with the macros stripped out of the file. Is there any way around this?
How does Excel Services "inject" data? Consider using a data connection in the Excel file instead.
To do that, create a view that shows the data you want and export to Excel. The file now has a data connection to the SharePoint list. You can configure the connection settings and use the data in the spreadsheet. You can hide the sheet with the SharePoint data if it messes up the workbook look.
Or, use the file "injected" with Excel Services as a source file and create a separate file that runs the VBA. Open the injected file and read its data with VBA.

Just set up SSIS and MS 2012, getting permissions error and don't know where to proceed?

I just started using SSIS and am trying to upload an Excel file. When I get to the Excel Connection Manager and use the variable pointing to the file path of it's location, I get the following error:
"An OLE DB record is available. Source: "Microsoft JET Database Engine" HRresult: 0x80004005 Description: "The Microsoft Jet database engine cannot open the file". IT is already opened exclusively by another user, or you need permission to view its data."
The SQL Server and SSIS software are brand new. The destination table is already set up. What could I try to fix the issue?
Looks like there is a lock on the file (on the server, right-click my computer, manager, system tools, shared folders, open files).
OR look for Excel Version in Excel connection manager, choose MS excel 97-2003. I assume you are using new version
Make sure you don't have the spreadsheet open in Excel, it will put a lock on the file and prevent it from being opened by SSIS.
sometimes if excel didn't close properly it might leave an instance in memory locking your file. You may need to check it with Task Manager and kill the excel instances manually.
Close out of Server Manager or Visual Studio. It will release the file.

oracle bi publisher excel template report error- output failed

I am using Oracle BI publisher. I created a Excel template report.
once generating the output for that report, I am not able to view the output in excel format. It throws error when I am opening the excel output file "The file you are trying to open, 'name.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?" if I gave yes for this error, the page is opening with no records of output.
I even tried by generating the XML file and loading that file in the excel template, then view, I am able to see the Output. but when uploading the same excel template in the BI application and view the output, it generates the excel output, but throwing the above error and not able to see the output.
The template which i uploaded has XDO_METADATA worksheet page.
I saved my excel template in excel 97-2003 worksheet in .xls format.
My oracle BI publisher desktop version - 11.1.1.7
Excel version- Microsoft excel 2007
Add-ins in excel- BI Publisher template builder for excel - type COM add-in
solver add-in - type excel add-in
We ran into this problem as well. On occasion it would just happen to one report, we would rebuild the excel template and that seemed to resolve the issue. However recently, our whole catalog was an issue. All the excel reports were getting the error, although they ran previously.
Turns out that the temp file on the application server was full. Our admin cleaned it out and restarted the BI service and that seems to have resolved the issue.

How to export data from Excel spreadsheet to Sql Server 2008 table

I want to import data from an Excel file - assume Excel 2003 / .xls - to Sql Server 2008.
Have tried adding a linked server to the JET OLE DB Access driver, and of course it fails on the 64-bit machine.
But when I try to drop the linked server while experimenting, there's another error saying that the linked server already/still exists!
I have also tried changing the Excel driver to 32-bit (regedit tool) but am not sure if it's doing anything, same error is coming up!
Some more details:
Say Table1 in Excel file has 5 columns.
I want to map to Database.dbo.Table1 with 5 columns again, but with different names in table.
Is there a way to do even do such an import?
From your SQL Server Management Studio, you open Object Explorer, go to your database where you want to load the data into, right click, then pick Tasks > Import Data.
This opens the Import Data Wizard, which typically works pretty well for importing from Excel. You can pick an Excel file, pick what worksheet to import data from, you can choose what table to store it into, and what the columns are going to be. Pretty flexible indeed.
You can run this as a one-off, or you can store it as a SQL Server Integration Services (SSIS) package into your file system, or into SQL Server itself, and execute it over and over again (even scheduled to run at a given time, using SQL Agent).
Update: yes, yes, yes, you can do all those things you keep asking - have you even tried at least once to run that wizard??
OK, here it comes - step by step:
Step 1: pick your Excel source
Step 2: pick your SQL Server target database
Step 3: pick your source worksheet (from Excel) and your target table in your SQL Server database; see the "Edit Mappings" button!
Step 4: check (and change, if needed) your mappings of Excel columns to SQL Server columns in the table:
Step 5: if you want to use it later on, save your SSIS package to SQL Server:
Step 6: - success! This is on a 64-bit machine, works like a charm - just do it!!
There are several tools which can import Excel to SQL Server.
I am using DbTransfer (http://www.dbtransfer.com/Products/DbTransfer) to do the job.
It's primarily focused on transfering data between databases and excel, xml, etc...
I have tried the openrowset method and the SQL Server Import / Export Assitant before.
But I found these methods to be unnecessary complicated and error prone in constrast to doing it with one of the available dedicated tools.
In SQL Server 2016 the wizard is a separate app. (Important: Excel wizard is only available in the 32-bit version of the wizard!). Use the MSDN page for instructions:
On the Start menu, point to All Programs, point toMicrosoft SQL Server , and then click Import and Export Data.
—or—
In SQL Server Data Tools (SSDT), right-click the SSIS Packages folder, and then click SSIS Import and Export Wizard.
—or—
In SQL Server Data Tools (SSDT), on the Project menu, click SSIS Import and Export Wizard.
—or—
In SQL Server Management Studio, connect to the Database Engine server type, expand Databases, right-click a database, point to Tasks, and then click Import Data or Export data.
—or—
In a command prompt window, run DTSWizard.exe, located in C:\Program Files\Microsoft SQL Server\100\DTS\Binn.
After that it should be pretty much the same (possibly with minor variations in the UI) as in #marc_s's answer.