in tFileInputExcel how to select the first sheet

Highlighted
One Star

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
Community Manager

Re: in tFileInputExcel how to select the first sheet

Hi
There is a sheetName text in the setting panel.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: in tFileInputExcel how to select the first sheet

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
One Star

Re: in tFileInputExcel how to select the first sheet

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 Smiley Sad
Regards
One Star

Re: in tFileInputExcel how to select the first sheet

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
One Star

Re: in tFileInputExcel how to select the first sheet

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 ?
One Star

Re: in tFileInputExcel how to select the first sheet

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.
One Star

Re: in tFileInputExcel how to select the first sheet

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

Yes thank's it's perfect

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog