Extracting data from specific Excel cells

Overview

Sometimes you will need to extract data from specific Excel cells rather than all of the data in the file. This article explains how to extract data from specific cells.

 

Environment

This procedure was written with:

  • Talend Open Studio for DI 5.0-r72978
  • JDK version: Sun JDK build 1.6.0_26-b03
  • Operating system: Windows XP SP3

Talend verified this procedure to be compatible with:

  • Data Integration releases: 4.2.3, 4.2.4, 5.0.0, 5.0.1, 5.0.2, 5.1.1

 

Procedure

Use an Excel file, as follows:

This example will extract data from cells D4 and B7.

1_031.png

 

Create an example Job

Create a Job called ExtractSpecificCellDemo. The detailed component settings are as follows:

2_027.png

 

3_010.png

 

4_011.png

 

5_009.png

 

The tJavaRow code:

int seq= Numeric.sequence("s1",1,1);
if (seq == 4) {
    context.d4 = input_row.c4;
}
if (seq == 7) {
    context.b7 = input_row.c2;
}

 

In this Job, two context variables are defined to store the data extracted from the specific cells.

 

Execute the Job

Execute the Job. The following text is output to the console:

Starting Job ExtractSpecificCellDemo at 15:47 02/02/2012.
  
[statistics] connecting to socket on port 3733
[statistics] connected
.--+--.
|tLogRow_1|
|=-+-=|
|d4|b7|
|=-+-=|
|D4|B7|
'--+--'
  
[statistics] disconnected
Job ExtractSpecificCellDemo ended at 15:47 02/02/2012. [exit code=0]
Version history
Revision #:
2 of 2
Last update:
‎06-22-2017 11:54 PM
Updated by:
 
Labels (1)