Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

load a Password protected Excel File to QlikView

Hi Guys,

Is it possible to load a Password protected Excel File to QlikView?

Thanks,

Aldo.

19 Replies
Not applicable
Author

flipside,

Something is missing in the call.

Where to use variable "x" ?

Which string should I use in variables cmdODBC / cmdSQL  ?

could you help, please?

Thanks in advance,

Aldo.

SET vFilePath ='C:\Temp\1.xls';    SET vExt ='(xls)';

SET vPwd1 ='a1';   SET vPwd2 ='a1';

SET cmdODBC ='';  // ???

SET cmdSQL ='';   // ???

LET x = OpenExcel(vFilePath,vExt,vPwd1,vPwd2);

ODBC CONNECT32 TO $(cmdODBC);   SQL $(cmdSQL); DISCONNECT;

LET x = CloseExcel();

flipside
Specialist II
Specialist II

Hi Aldo,

I've probably complicated the code by using the 2 variables, you can simply replace them with your required ODBC connection string and SELECT command.  When you do that, you will notice the filepath repeats 3 times overall in the code (in the function call, in the connection string and in the select command), so once you are up and running, you can then look at tidying up the code to use variables - just makes everything neater and more manageable.

The variable x is used in this case to solely call the function, you may not always get a return value but in these functions no return value is needed anyway.

In the OpenExcel function, the filepath needs submitting without the extension, so your variables need to be ...

     SET vFilePath ='C:\Temp\1';    SET vExt ='.xls';

... this will make sense when you look at the filepath in the select command.

One issue you may encounter as you set this up and do your testing, is you may inadvertently open multiple instances of Excel, so check this out in Task Manager and ensure none are running before each testing stage as this could cause a failure to access the workbook.

Hope this works for you.

flipside

Not applicable
Author

any chance to have an example of conn string and sql query ? (sql query to excel...?)

Thanks.

Aldo.

flipside
Specialist II
Specialist II

Yeah sure.

I take it you have already created an excel driver ODBC connection, which you should be able to select in QV script using the Connect... button.  This will generate something like ...

ODBC CONNECT32 TO [Excel Files;DBQ=U:\QV\Sandpit\ProtectedFile.xls];

... where "Excel Files" is the name of the DSN and the filepath (DBQ) is the source file.  If the file isn't already open the ODBC wizard will fail, so open the Excel file first.  After that use the Select wizard to generate the SQL code directly below the ODBC code, something like ...

SQL SELECT *

FROM `U:\QV\SANDPIT\Protected`.`Sheet1$`;

flipside

View solution in original post

Not applicable
Author

Got it working, thanks !

Aldo.

ivan_will
Partner
Partner

?

marcus_sommer
MVP & Luminary
MVP & Luminary

Possibly an alternative:

http://community.qlik.com/message/350934#350934

- Marcus

Not applicable
Author

Hi,

I have created the macro which opens the file in excel and decrypts it, then there is the code that via the ODBC connects with the excel and reads the data. All according to the steps presented by the User Flipside.

Everything works perfectly when I trigger it within the Qlikview designer. When I try to start the task via QMC it gives the error:

Error: SQL##f - SqlState: S1000, ErrorCode: 4294962291, ErrorMsg: [Microsoft][ODBC Excel Driver] Could not decrypt file.

Have you tried to reload the qvw file which decrypts the excel file via the chain in QMC? Why is it not working?

Thanks for any suggestions.

Asia

Not applicable
Author

It works if I keep the protected excel open. I dont thinks a correct workaround. I rather encrypt the password in QV script but keeping an workbook open in excel doesnt sound right.

Is my understanding correct? Anyone else had a different way to do this?

Thanks,

Ganesh

datanibbler
Champion
Champion

Hi,

I was just redirected here by a link since I have the same issue.

I seem to have no Excel_ODBC_driver or whatever. The "connect" and "select"  buttons don't work - the list is empty, no databases selectable.

Also, I cannot keep the Excel_file open every time I need to reload the data from them.

What do I have to do now?

Thanks a lot!

Best regards,

DataNibbler