Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
qw_johan
Creator
Creator

Loading Excel files

Hi!

I am loading multiple excel files from a specific folder using a for each loop. This works fine.
My problem is that the structure of some excel files isn't what I am expecting it to be (there are two different versions / structures). The number of columns change from 7 to 10 and the fieldnames (column lables) are different. I know I could manually edit the files but i wish to avoid that.
How do I deal with this situation? Can qlikview help me?

I read about SQLColumns and with that I should be able to count the number of columns in an excel file before it is loaded, but I can't get it to work. My odbc connection keeps failing, Message...SQL##f - SqlState: 42000, ErrorCode: 4294965487 ..

ODBC CONNECT TO [Excel Files;DBQ='C:\Lists\9786438.xls];
columns:
SQLColumns;

DISCONNECT;

Is there other techniques or ways to get around the problem with loading multiple excelfiles into Qlikview when u have files with different number of columns and/or different column names ?

I would really appreciate some help on this.
I attached an example qvw file of how I load excel files.

Thanks

4 Replies
prieper
Master II
Master II

The script should work - have you checked to load the file without the SQLCOLUMNS? Probably you are missing some drivers during last installation?
Have tried it under vers 10 - works. You may then add an inspection, like IF NOOFROWS('Columns') = 7 THEN ... ELSE ... END IF

HTH
Peter

qw_johan
Creator
Creator
Author

Hi,

Thanks for your reply. I got it to work now. I changed my connect string (also had to remove ODBC)...
CONNECT TO [Provider=Microsoft.Jet.OLEDB.4.0;Data Source='$(vFile)';Extended Properties="Excel 8.0;"];

Thanks

qw_johan
Creator
Creator
Author

Hi

qw_johan
Creator
Creator
Author

Hi Peter,

It doesn't workSad. I thought it did work but it doesn't.
Problem:If the excel documents that i am loading contains more than one sheet, and all sheets have some information, i get an error saying that it can't find the fields that i want to load. If the excel documents only has one sheet, one sheet only, it works ok. Why is this? I attach my qvw if it helps.
I only want to load the first sheet, always the first sheet

Thanks