March 18, 2010 at 12:28 pm
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?
March 23, 2010 at 3:34 pm
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
March 24, 2010 at 7:35 am
Shoot! Anyway to programatically remove the password protection so that it can be used in SSIS?
March 24, 2010 at 9:03 am
Maybe, but unfortunately I don't have any information on that.
CEWII
March 25, 2010 at 8:23 am
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:
March 25, 2010 at 9:07 am
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!
March 25, 2010 at 9:31 am
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:
March 25, 2010 at 9:51 am
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>)
Thoughts?
March 25, 2010 at 10:12 am
Nevermind, I was able to get this to work. Thanks for your insight on this!
June 9, 2010 at 9:26 pm
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!
May 26, 2014 at 2:01 am
i tried the above script but it still prompts me for a password after the type this line
$wb = $xl.Workbooks.Open("C:\Scripts\Test.xls",0,$False,1,"%reTG54w")
i have given my password for my excel file for my code.
im not even able to type the next line unless i enter the password for the excel file. If the close the excel file it throws an error in the powershell!
Is there any way to solve this issue. The code worked fine two days back!
thanks in advance
August 23, 2019 at 10:43 am
With the help of SDR excel password recovery software that guide you healthy option to recover lost excel file password by using brute force attack, mask attack and dictionary attack. This software is well perfect to reset lost forget excel file password.
Read more:- https://www.stelladatarecovery.com/free-2010-excel-password-recovery-tool.html
August 23, 2019 at 10:43 am
February 7, 2020 at 5:34 am
This reply has been reported for inappropriate content.
Wonderful Software to Excel Password Recovery protection by Atom TechSoft Recover Excel Password Software is easily remove your excel password without any damage. This application recover Excel file password quecly with supported version upto 2019.
Read More :- https://www.atomtechsoft.com/unlockexcel2016/
Viewing 14 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy