SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS using source of password-protected Excel Files


SSIS using source of password-protected Excel Files

Author
Message
aber
aber
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2559 Visits: 239
I need to import data from an Excel file into a SQL 2005 DB and thought I would use SSIS since this is a pretty straight forward task for SSIS. However, I just learned that the Excel file is password-protected and I have not found anything online that mentions how to do this since there is no way to distinguish this in the Connection to the Excel file.
I do know the password to open the file but just don't know how to automate this. Any ideas?
Elliott Whitlow
Elliott Whitlow
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10076 Visits: 5314
You can't..

http://msdn.microsoft.com/en-us/library/ms139836.aspx
Important text in the article:
You cannot connect to a password-protected Excel file.

CEWII
aber
aber
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2559 Visits: 239
Shoot! Anyway to programatically remove the password protection so that it can be used in SSIS?
Elliott Whitlow
Elliott Whitlow
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10076 Visits: 5314
Maybe, but unfortunately I don't have any information on that.

CEWII
John McC
John McC
Say Hey Kid
Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)

Group: General Forum Members
Points: 702 Visits: 1678
My first thought was that you may be able to use Poweshell. A quick look around and I found this:

http://www.eggheadcafe.com/software/aspnet/34092087/can-i-open-a-password-pro.aspx

-------------------------------------------------------------------------
Normal chaos will be resumed as soon as possible. Crazy
aber
aber
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2559 Visits: 239
Great, I was able to open the Excel file using Powershell, thanks! Since I'm very new to Powershell, is there a way to save the Excel file without the password now?
Here's my thoughts. Open the Excel file and save it without the password. Then use SSIS to reference this newly saved file as a source for data flow to get around the limitation of not being able to open it in SSIS with a password.
Any thouhts?
Thanks!
John McC
John McC
Say Hey Kid
Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)Say Hey Kid (702 reputation)

Group: General Forum Members
Points: 702 Visits: 1678
Exactly that. Set password to empty ("") and SaveAs. Then the connection manager shouldn't complain.


$comments = @'
Script name: Remove-Password.ps1
Created on: Tuesday, July 03, 2007
Author: Kent Finkle
Purpose: How can I use Windows Powershell to
Remove the Password When Opening an Excel Spreadsheet?
'@
#-----------------------------------------------------
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]::ReleaseComObject(
[System.__ComObject]$ref) -gt 0)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
}
#-----------------------------------------------------
$xl = new-object -comobject excel.application

$xl.Visible = $True

$xl.DisplayAlerts = $False

$wb = $xl.Workbooks.Open("C:\Scripts\Test.xls",0,$False,1,"%reTG54w")

$wb.Password = ""

$a = $wb.SaveAs( "C:\Scripts\Test.xls")

$a = Release-Ref($wb)
$a = Release-Ref($xl)



-------------------------------------------------------------------------
Normal chaos will be resumed as soon as possible. Crazy
aber
aber
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2559 Visits: 239
I try this and I'm getting the following error on the saveas line:
Exception calling "SaveAs" with "1" arguments(s): "Cannot access read-only document

I have "$False" for the readonly parameter on the open method so I don't understand why I'm getting this error.
Here's the Open statement
$wb = $xl.Workbooks.Open(<file>,1,$False,5,"abc123","abc123")
Here's the SaveAs statement
$a = $wb.SaveAs(<file>Wink

Thoughts?
aber
aber
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2559 Visits: 239
Nevermind, I was able to get this to work. Thanks for your insight on this!
CozyRoc
CozyRoc
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2384 Visits: 2235
aber (3/18/2010)
I need to import data from an Excel file into a SQL 2005 DB and thought I would use SSIS since this is a pretty straight forward task for SSIS. However, I just learned that the Excel file is password-protected and I have not found anything online that mentions how to do this since there is no way to distinguish this in the Connection to the Excel file.
I do know the password to open the file but just don't know how to automate this. Any ideas?


If you can use third-party solutions, check the commercial CozyRoc Excel components. These are the relevant components:

* Excel Source component - for reading data from Excel worksheet.
* Excel Destination component - for writing data in Excel worksheet.
* Excel Task - for manipulating Excel workbooks.
* Excel Connection - used by the components above and also for implementing custom scripts based on it.

The Excel Connection supports opening of password-protected workbooks and doesn't require installation of Office. Cheers!

---
SSIS Tasks Components Scripts Services | http://www.cozyroc.com/


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search