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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

in tFileInputExcel how to select the first sheet

Hi
When using tFileInputExcel I have to gave the name of the sheet I want to use.
Is there a way to tell the component I want to use the first sheet of the excel file (actualy my excel file have only one sheet)
Regards
Labels (2)
7 Replies
Anonymous
Not applicable
Author

Hi
There is a sheetName text in the setting panel.
Best regards
shong
Anonymous
Not applicable
Author

Hello Paulo,
I think there is no actual solution for your need. Isn't it possible to ensure that the sheet has every time the same name?
Bye
Volker
Anonymous
Not applicable
Author

I think there is no actual solution for your need. Isn't it possible to ensure that the sheet has every time the same name?

The best thing I could have is to have the sheet name to be PREFIXYYYYMMDD, with PREFIX a constant and YYYYMMDD a constant but could be another day (in the past) than Today.
Maybe I could try with YYYYMMDD with today's date then if error yesterday, then if error the day before....
But not sure it's easy to do 0683p000009MPcz.png
Regards
Anonymous
Not applicable
Author

Hello Paulo,
depending on your java knowledge you can have a look into the generated source. The workbook is accessed with jxl.Workbook. Take a look into the API http://docjar.com/docs/api/jxl/Workbook.html you will find a method getSheetNames().
I'm not sure, but it may be possible access the data in a tJavaFlex and extract the sheet-names.
Bye
Volker
Anonymous
Not applicable
Author

There is a sheetName text in the setting panel.

Shong, the request is to use the first sheet of the Excel workbook (not the one named "shhet1") should I post a feature request ?
Anonymous
Not applicable
Author

Try this:
1) define a context variable: context.firstSheetName
2) Use a tJava_1 component
3) The code inside the tJava_1 should be:

jxl.Workbook workbook = jxl.Workbook.getWorkbook(new java.io.File("C:/Documents and Settings/petrutz/My Documents/TOD-in.xls"));
java.lang.String firstSheetName = new java.lang.String(workbook.getSheetNames());
context.firstSheetName=firstSheetName;
workbook.close();
4) Use a tFileInputExcel
in the SheetName field you should use: context.firstSheetName
5) Use a tLogRow
activate the logging here
6) connect tJava to tFileInputExel with a onSubjobOK to the tFileInputExcel
7) connect the tFileInputExcel to the tLogRow with the main.
Hope it will help.
Anonymous
Not applicable
Author

Try this:
....
Hope it will help.

Yes thank's it's perfect