Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
msg1
Contributor
Contributor

In tJavaRow, how to skip to the next sheet?

Hello,

My goal is to extract data from multiple sheets from an Excel file, while avoiding to loop over all rows of all sheets, given that a prior process stashed the last line to exploit in each sheet if any.

So here a tFileInputExcel feeds a tJavaRow, and basiacally, after looking at the generated text.

 

Basically, I’m looking for a way to express "if some condition are met, skip the rest of rows contained on the current sheet, and move to the next one".

 

Here is a concrete example of what I tried to implement :

String sheet = (String) globalMap.get("tFileInputExcel_2_CURRENT_SHEET");

boolean process = true;

for(String key: globalMap.keySet()) {

 process = key.matches(sheet + "\\d\\+"); // globalMap contains a "shitname + row-number" key for each line to process

 if(!process) {break;}

}

if(!process) {

 System.out.println( String.format("Skip sheet '%s': no matching data to extract.", sheet) );

/* Here is code copied from the generated code that I thought possibly relevant to achieve the stated goal */

                      if (rowCount_tFileInputExcel_2 <= i_tFileInputExcel_2) {

                        sheet_tFileInputExcel_2 = sheetList_tFileInputExcel_2

                              .get(++sheetIndex_tFileInputExcel_2);

                        currentRows_tFileInputExcel_2 = sheet_tFileInputExcel_2.getRows();

                        }

/* End of code copied from the generated one */

 continue;

}

Now, when run, this will lead to the Exception with the message "Exception in component tJavaRow_1 (Parse_Excel_6)":

Exception in component tJavaRow_1 (Parse_Excel_6)

java.lang.IndexOutOfBoundsException: Index: 37, Size: 37

   at java.util.ArrayList.rangeCheck(Unknown Source)

   at java.util.ArrayList.get(Unknown Source)

   at ars.parse_excel_6_0_1.Parse_Excel_6.tFileInputExcel_2Process(Parse_Excel_6.java:7883)

   at ars.parse_excel_6_0_1.Parse_Excel_6.tFileInputExcel_1Process(Parse_Excel_6.java:1357)

   at ars.parse_excel_6_0_1.Parse_Excel_6.runJobInTOS(Parse_Excel_6.java:8371)

   at ars.parse_excel_6_0_1.Parse_Excel_6.main(Parse_Excel_6.java:8220)

Would someone have some recommendation? Likely this is due to the increment of the sheet pointer going to far, but I didn’t figure out how to deal properly with the context produced with the generated code.

0 Replies