public String getData()

in javav2/usecases/Creating_etl_workflow/src/main/java/com/etl/example/ExcelService.java [31:135]


    public String getData(String bucketName, String object) throws IOException, BiffException {

    // Get the Excel speadsheet from the Amazon S3 bucket.
    S3Service s3Service = new S3Service();
    byte[] data = s3Service.getObjectBytes(bucketName, object);
    InputStream inputStrean = new ByteArrayInputStream(data);

    List<PopData> myList = new ArrayList() ;
    System.out.println("Retrieving data from the Excel Spreadsheet");
    Workbook wb = Workbook.getWorkbook(inputStrean);
    Sheet sheet = wb.getSheet(0);

    try{

        // Read the data from the excel spreadsheet.
        Sheet s=wb.getSheet(0);
        int b = s.getColumns();
        System.out.println("The No. of Columns in the Sheet are = " + b);
        int a = s.getRows();
        System.out.println("The No. of Rows in the sheet are = " +a);

        PopData popData = null;

        // Loop through the rows in the spreadsheet.
        for (int zz = 0 ; zz <a; zz++) {

            // Get the first cell.
            System.out.println(zz);

            Cell[] row = sheet.getRow(zz);

            if (zz ==0)
               System.out.println("Not 1st row");
            else {
              popData = new PopData();

            for (Cell cell : row) {

                int colIndex =  cell.getColumn();
                String val = cell.getContents();

                switch(colIndex) {
                    case 0:
                        popData.setName(val);
                        break;

                    case 1:
                        popData.setCode(val);
                        break;

                    case 2:
                        popData.set2010(val);
                        break;

                    case 3:
                        popData.set2011(val);
                        break;

                    case 4:
                        popData.set2012(val);
                        break;

                    case 5:
                        popData.set2013(val);
                        break;

                    case 6:
                        popData.set2014(val);
                        break;

                    case 7:
                        popData.set2015(val);
                        break;

                    case 8:
                        popData.set2016(val);
                        break;

                    case 9:
                        popData.set2017(val);
                        break;

                    case 10:
                        popData.set2018(val);
                        break;

                    default: {
                        popData.set2019(val);
                        myList.add(popData);
                    }
                }
            }
        }
    }

        myList.sort(Comparator.comparing(PopData::getName));
        String transformXML  = convertToString(toXml(myList));
        return transformXML;

    }catch (Exception e) {
        e.printStackTrace();
    }

    return "";
    }