'Please guide: I want to use payload variable created in excelutility class to another java executable class
Trying to use payload variable extracted from an excel sheet in another executable class where I want to post the payload on MQ, although not able to access the variable. How can I use this variable to other class.
package datasource;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileInputStream;
import java.io.IOException;
public class excelUtility {
public static void main(String[] args) throws IOException {
String excelfilePath= "src/main/resources/Book1.xlsx";
FileInputStream inputStream= new FileInputStream(excelfilePath);
XSSFWorkbook workbook=new XSSFWorkbook(inputStream);
XSSFSheet sheet= workbook.getSheet("sheet1");
int rows= sheet.getLastRowNum();
int cols= sheet.getRow(1).getLastCellNum();
for (int r=0; r<=rows; r++){
XSSFRow row= sheet.getRow(r);
for(int c=0; c<cols; c++){
XSSFCell cell= row.getCell(1);
String payload= cell.getStringCellValue();
System.out.println(payload);
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|