Example usage for org.apache.poi.xssf.usermodel XSSFCell getStringCellValue

List of usage examples for org.apache.poi.xssf.usermodel XSSFCell getStringCellValue

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFCell getStringCellValue.

Prototype

@Override
public String getStringCellValue() 

Source Link

Document

Get the value of the cell as a string

For numeric cells we throw an exception.

Usage

From source file:ru.letoapp.tests.RegistrationQuickDDTest.java

public String[][] getTestDataFromXlsxFile() throws Exception {
    String path = "src/main/resources/TestData.xlsx";
    String[][] dataList = new String[2][2];
    FileInputStream fis = null;/*from w  w  w.j  av  a 2 s  .  com*/
    try {
        fis = new FileInputStream(new File(path));
        XSSFWorkbook workbook = new XSSFWorkbook(fis);
        XSSFSheet sheet = workbook.getSheet("TestData");
        Iterator<Row> rows = sheet.rowIterator();
        if (rows.hasNext()) {
            rows.next();
        }
        for (int i = 0; rows.hasNext(); ++i) {
            XSSFRow row = ((XSSFRow) rows.next());
            Iterator<Cell> cells = row.cellIterator();
            for (int j = 0; cells.hasNext(); ++j) {
                XSSFCell cell = (XSSFCell) cells.next();
                String value = cell.getStringCellValue();
                if (!value.equals(null)) {
                    dataList[i][j] = value;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dataList;
}

From source file:singleton.StaticClass.java

public synchronized void copyFromExcel(String fileName) throws IOException {
    //System.out.println("start");
    Data temp;/*from  w ww .j a  va2 s.c o m*/
    String value = "";

    File inFile = new File(fileName);
    FileInputStream file = new FileInputStream(inFile);

    XSSFWorkbook wb = new XSSFWorkbook(file);
    XSSFSheet sheet = wb.getSheetAt(4); // Build Image Analysis page is at
    // the 4th sheet of Open source
    // license excel file.

    int rows = sheet.getPhysicalNumberOfRows();

    for (int i = 2; i < rows; ++i) { // start index should be 2 since the
        // 1st row is used for titles.
        XSSFRow row = sheet.getRow(i);
        if (row != null) {

            int cells = row.getPhysicalNumberOfCells(); // Number of cells
            // at each row.

            temp = new Data();
            for (int colIndex = 1; colIndex <= cells; colIndex++) {
                XSSFCell cell = row.getCell(colIndex);

                if (colIndex == 1) {
                    switch (cell.getCellType()) {
                    case XSSFCell.CELL_TYPE_BLANK:
                        temp.setBinary("");
                        break;
                    case XSSFCell.CELL_TYPE_STRING:
                        temp.setBinary(cell.getStringCellValue());
                        break;
                    }
                } else if (colIndex == 2) {
                    switch (cell.getCellType()) {
                    case XSSFCell.CELL_TYPE_BLANK:
                        temp.setPath("");
                        break;
                    case XSSFCell.CELL_TYPE_STRING:
                        temp.setPath(cell.getStringCellValue());
                        break;
                    }
                } else if (colIndex == 3) {
                    switch (cell.getCellType()) {
                    case XSSFCell.CELL_TYPE_BLANK:
                        temp.setOnok("");
                        break;
                    case XSSFCell.CELL_TYPE_STRING:
                        value = cell.getStringCellValue();
                        temp.setOnok(value);
                        break;
                    }
                } else if (colIndex == 4) {
                    switch (cell.getCellType()) {
                    case XSSFCell.CELL_TYPE_BLANK:
                        temp.setOssComponent("");
                        break;
                    case XSSFCell.CELL_TYPE_STRING:
                        temp.setOssComponent(cell.getStringCellValue());
                        break;
                    }
                } else if (colIndex == 6) {
                    switch (cell.getCellType()) {
                    case XSSFCell.CELL_TYPE_BLANK:
                        temp.setLicense("");
                        break;
                    case XSSFCell.CELL_TYPE_STRING:
                        temp.setLicense(cell.getStringCellValue());
                        break;
                    }
                } else {
                    continue;
                }
            }
            if (temp != null) {
                if (value.equalsIgnoreCase("nok")) {
                    nokList.add(temp);
                    //System.out.println("nok count : " + nokList.size());
                } else if (value.equalsIgnoreCase("ok")) {
                    okList.add(temp);
                    //System.out.println("ok count : " + okList.size());
                } else if (value.equalsIgnoreCase("nok(na)")) {
                    nokNaList.add(temp);
                    //System.out.println("nok(na) count : " + nokNaList.size());
                } else {
                    blankList.add(temp);
                    //System.out.println("blank count : " + blankList.size());
                }
                System.out.println(temp.getBinary() + "\t" + temp.getPath() + "\t\t" + temp.getOnok() + "\t\t"
                        + temp.getLicense());
            }
        }
    }
}

From source file:sv.com.mined.sieni.controller.GestionNotasController.java

public static void copyRow(XSSFSheet worksheetSource, XSSFSheet worksheetDestination, int sourceRowNum,
        int destinationRowNum) {
    // Get the source / new row
    XSSFRow origen = worksheetSource.getRow(sourceRowNum);
    XSSFRow destino = worksheetDestination.createRow(destinationRowNum);

    // Loop through source columns to add to new row
    for (int i = 0; i < origen.getLastCellNum(); i++) {
        // Grab a copy of the old/new cell
        XSSFCell oldCell = origen.getCell(i);
        XSSFCell newCell = destino.createCell(i);
        // If the old cell is null jump to next cell
        if (oldCell == null) {
            newCell = null;//from  w w  w .jav  a2s .c  om
            continue;
        }

        //Ajustar tamaos columnas
        worksheetDestination.setColumnWidth(i, worksheetSource.getColumnWidth(i));

        // Copy style from old cell and apply to new cell
        XSSFCellStyle newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();
        newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
        newCell.setCellStyle(newCellStyle);

        // If there is a cell comment, copy
        if (oldCell.getCellComment() != null) {
            newCell.setCellComment(oldCell.getCellComment());
        }

        // If there is a cell hyperlink, copy
        if (oldCell.getHyperlink() != null) {
            newCell.setHyperlink(oldCell.getHyperlink());
        }

        // Set the cell data type
        newCell.setCellType(oldCell.getCellType());
        // Set the cell data value
        switch (oldCell.getCellType()) {
        case Cell.CELL_TYPE_BLANK:
            newCell.setCellValue(oldCell.getStringCellValue());
            break;
        case Cell.CELL_TYPE_BOOLEAN:
            newCell.setCellValue(oldCell.getBooleanCellValue());
            break;
        case Cell.CELL_TYPE_ERROR:
            newCell.setCellErrorValue(oldCell.getErrorCellValue());
            break;
        case Cell.CELL_TYPE_FORMULA:
            newCell.setCellFormula(oldCell.getCellFormula());
            break;
        case Cell.CELL_TYPE_NUMERIC:
            newCell.setCellValue(oldCell.getNumericCellValue());
            break;
        case Cell.CELL_TYPE_STRING:
            newCell.setCellValue(oldCell.getRichStringCellValue());
            break;
        }

    }

}

From source file:tan.jam.jsf.Shifting.java

public static int FindShift(XSSFWorkbook workbook, XSSFSheet worksheet) {
    String s = "TOTAL BANKS";
    XSSFRow Row = worksheet.getRow(2);//from ww w  .  j a  v a  2s  .  c o m
    for (int i = 9; i < 26; i++) {
        XSSFCell cell = Row.getCell(i);
        String g = cell.getStringCellValue();
        if (g.equals("TOTAL BANKS")) {
            return i - 9;
        }
    }
    return 0;
}

From source file:tan.jam.jsf.Shifting.java

public static void InsertRow(XSSFWorkbook workbook, XSSFSheet worksheet, int sourceRowNum,
        int destinationRowNum) {

    worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
    XSSFRow newRow = worksheet.getRow(destinationRowNum);
    XSSFRow sourceRow = worksheet.getRow(sourceRowNum);

    if (newRow != null) {
        worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
    } else {/*from w ww.  java 2s.  c  om*/
        newRow = worksheet.createRow(destinationRowNum);
    }

    for (int i = 0; i < sourceRow.getLastCellNum(); i++) {
        // Grab a copy of the old/new cell
        XSSFCell oldCell = sourceRow.getCell(i);
        XSSFCell newCell = newRow.createCell(i);

        if (oldCell == null) {
            newCell = null;
            continue;
        }

        XSSFCellStyle newCellStyle = workbook.createCellStyle();
        newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
        ;
        newCell.setCellStyle(newCellStyle);

        if (oldCell.getCellComment() != null) {
            newCell.setCellComment(oldCell.getCellComment());
        }

        if (oldCell.getHyperlink() != null) {
            newCell.setHyperlink(oldCell.getHyperlink());
        }

        newCell.setCellType(oldCell.getCellType());

        switch (oldCell.getCellType()) {
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
            newCell.setCellValue(oldCell.getStringCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
            newCell.setCellValue(oldCell.getBooleanCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
            newCell.setCellErrorValue(oldCell.getErrorCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
            newCell.setCellFormula("+" + "F" + destinationRowNum + "*G" + destinationRowNum);
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
            //newCell.setCellValue(oldCell.getNumericCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
            newCell.setCellValue("");
            break;
        }
    }

    for (int i = 0; i < worksheet.getNumMergedRegions(); i++) {
        CellRangeAddress cellRangeAddress = worksheet.getMergedRegion(i);
        if (cellRangeAddress.getFirstRow() == sourceRow.getRowNum()) {
            CellRangeAddress newCellRangeAddress = new CellRangeAddress(newRow.getRowNum(),
                    (newRow.getRowNum() + (cellRangeAddress.getLastRow() - cellRangeAddress.getFirstRow())),
                    cellRangeAddress.getFirstColumn(), cellRangeAddress.getLastColumn());
            worksheet.addMergedRegion(newCellRangeAddress);
        }
    }
    int inc = destinationRowNum + 1;
    worksheet.getRow(destinationRowNum).getCell(7).setCellFormula("+F" + inc + "*G" + inc);
}

From source file:tan.jam.jsf.Shifting.java

private static void CopyData(XSSFWorkbook workbook, XSSFSheet worksheet, int sourceRowNum,
        int destinationRowNum, int Mov) {
    XSSFRow newRow = worksheet.getRow(destinationRowNum);
    XSSFRow sourceRow = worksheet.getRow(sourceRowNum);

    for (int i = sourceRow.getLastCellNum(); i > 8 + Mov; i--) {

        int d = i - 1;
        XSSFCell oldCell = sourceRow.getCell(d);
        XSSFCell newCell = newRow.createCell(i);

        if (oldCell == null) {
            newCell = null;//from w ww .  j  av a  2  s. c o m
            continue;
        }

        XSSFCellStyle newCellStyle = workbook.createCellStyle();
        newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
        ;
        newCell.setCellStyle(newCellStyle);

        if (oldCell.getCellComment() != null) {
            newCell.setCellComment(oldCell.getCellComment());
        }

        if (oldCell.getHyperlink() != null) {
            newCell.setHyperlink(oldCell.getHyperlink());
        }

        newCell.setCellType(oldCell.getCellType());

        switch (oldCell.getCellType()) {
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
            newCell.setCellValue(oldCell.getStringCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
            newCell.setCellValue(oldCell.getBooleanCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
            newCell.setCellErrorValue(oldCell.getErrorCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
            newCell.setCellFormula(oldCell.getCellFormula());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
            newCell.setCellValue(oldCell.getNumericCellValue());
            break;
        case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
            newCell.setCellValue(oldCell.getRichStringCellValue());
            break;
        }
    }
}

From source file:uk.ac.bbsrc.tgac.miso.core.util.FormUtils.java

License:Open Source License

private static String getCellValueAsString(XSSFCell cell) {
    if (cell != null) {
        switch (cell.getCellType()) {
        case XSSFCell.CELL_TYPE_BLANK:
            return null;
        case XSSFCell.CELL_TYPE_BOOLEAN:
            return String.valueOf(cell.getBooleanCellValue());
        case XSSFCell.CELL_TYPE_ERROR:
            return cell.getErrorCellString();
        case XSSFCell.CELL_TYPE_FORMULA:
            return cell.getRawValue();
        case XSSFCell.CELL_TYPE_NUMERIC:
            return String.valueOf(cell.getNumericCellValue());
        case XSSFCell.CELL_TYPE_STRING:
            return cell.getStringCellValue();
        default:// w w  w  .j  a va  2  s  .c om
            return null;
        }
    }
    return null;
}

From source file:utils.ReadWriteExcelFile.java

public static void readXLSXFile(String aFile, int SheetNo) throws IOException {

    InputStream ExcelFileToRead = new FileInputStream(aFile);
    XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);

    XSSFWorkbook test = new XSSFWorkbook();

    XSSFSheet sheet = wb.getSheetAt(SheetNo);
    XSSFRow row;// w  w w. j  ava 2s  .c  o m
    XSSFCell cell;
    CTSheetDimension dimension = sheet.getCTWorksheet().getDimension();
    String sheetDimensions = dimension.getRef();
    System.out.println(sheetDimensions);
    List<String> dimensions = StringUtils.split(sheetDimensions, ":", true);
    String[] Dimensions = dimensions.get(1).toString().split("(?<=\\D)(?=\\d)");
    int Colums = CharToInt(Dimensions[0]);
    int Rows = Integer.parseInt(Dimensions[1]);
    System.out.println();
    Iterator rows = sheet.rowIterator();
    ArrayList[][] TableName = new ArrayList[Rows][Colums];
    System.out.println(TableName.length);
    int currentRow = 0;
    while (rows.hasNext()) {

        row = (XSSFRow) rows.next();
        Iterator cells = row.cellIterator();
        int currentCell = 0;
        //         System.out.println("currentRow="+currentRow+" And Current Colum is ="+currentCell);
        while (cells.hasNext()) {
            cell = (XSSFCell) cells.next();

            if (cell.getStringCellValue().isEmpty()) {
                TableName[cell.getRowIndex()][cell.getColumnIndex()].add(" - ");
                //               System.out.print(cell.getStringCellValue()+" ");
                //                                        TableName[currentRow][currentCell].add(" ");
                //            System.out.println("Cell Value is : "+cell.toString());
                //                                System.out.println("Empty cell currentRow="+currentRow+" And Current Colum is ="+currentCell);

            } else if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
                System.out.println("current Row=" + cell.getRowIndex() + " And Current Colum is ="
                        + cell.getColumnIndex());
                System.out.println(cell.getRichStringCellValue());
                TableName[cell.getRowIndex()][cell.getColumnIndex()]
                        .add(cell.getRichStringCellValue().toString());
                //                                    System.out.println("Cell Type is :"+cell.getCellType());
                //                                    System.out.println("Cell Value is : "+cell.getRichStringCellValue());
            } else if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
                TableName[cell.getRowIndex()][cell.getColumnIndex()].add(cell.getNumericCellValue());
                //                                    System.out.println("Cell Type is :"+cell.getCellType());
                //                                    System.out.println("current Row="+cell.getRowIndex()+" And Current Colum is ="+cell.getColumnIndex());
                //                                    int numericValue = (int) cell.getNumericCellValue();
                //                                    System.out.println("Cell Value is : "+numericValue);

            }
            //            else
            //            {
            //               //U Can Handel Boolean, Formula, Errors
            //            }
            currentCell++;
        }
        System.out.println();
        currentRow++;
    }
    for (int i = 0; TableName.length > i; i++) {
        for (int j = 0; TableName[i].length > j; j++) {
            System.out.println(TableName[i][j].toString());
        }

    }
}

From source file:vn.vnpttech.ssdc.nms.webapp.action.MatAction.java

License:Apache License

private List<Materials> processExcelFile(File file) throws IOException {
    List<Materials> list = new ArrayList<Materials>();

    //try {//from   w w w.j  av  a2s  . co m
    // Creating Input Stream
    FileInputStream myInput = new FileInputStream(file);

    // Create a workbook using the File System 
    XSSFWorkbook myWorkBook = new XSSFWorkbook(myInput);

    // Get the first sheet from workbook 
    XSSFSheet mySheet = myWorkBook.getSheetAt(0);

    Materials item = new Materials();

    /**
     * We now need something to iterate through the cells.*
     */
    Iterator<Row> rowIter = mySheet.rowIterator();
    while (rowIter.hasNext()) {
        XSSFRow myRow = (XSSFRow) rowIter.next();
        if (myRow.getRowNum() != 0) {// loi b? header

            Iterator<Cell> cellIter = myRow.cellIterator();
            while (cellIter.hasNext()) {
                XSSFCell myCell = (XSSFCell) cellIter.next();

                if (myCell.getCellType() != HSSFCell.CELL_TYPE_STRING) {
                    myCell.setCellType(Cell.CELL_TYPE_STRING);
                }
                String value = myCell.getStringCellValue().trim();

                switch (myCell.getColumnIndex()) {
                case 0: //stt ko lam gi
                    //                        item.setProvince(value);
                    break;

                case 1: //name
                    item.setName(value);
                    break;

                //                        case 2: //unit
                //                            if (StringUtils.isNotBlank(value)) {
                //                                item.setUnit(Double.parseDouble(value));
                //                            } else {
                //                                item.setUnit(0);
                //                            }
                //                            break;
                case 2: //unit price
                    if (StringUtils.isNotBlank(value)) {
                        item.setUnitPrice(Double.parseDouble(value));
                    } else {
                        item.setUnitPrice(0.0);
                    }
                    break;

                case 3: //weight
                    if (StringUtils.isNotBlank(value)) {
                        item.setWeight(Double.parseDouble(value));
                    } else {
                        item.setWeight(0.0);
                    }
                    break;

                default:
                    break;
                }

            }
            list.add(item);

            if (item.getName() != null) {
                item = new Materials(); //for next row
            }

        }
    }
    return list;
}

From source file:Wael.UI.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    //start if the button

    //aliases variables

    try {/*from  w  w w  .  j ava2  s .c  o m*/

        if (jRadioButton1.isSelected())

        {

            //Brocade Configuration variables        
            int a;
            int b;

            int c;
            int d;

            int e;
            int f;

            File file = new File(jTextField2.getText() + "\\" + jTextField3.getText());
            file.createNewFile();
            FileWriter brocadefile = new FileWriter(file);

            FileInputStream fileinputstream = new FileInputStream(jTextField1.getText());
            XSSFWorkbook workbook = new XSSFWorkbook(fileinputstream);

            XSSFSheet alisheet = workbook.getSheet("Aliases");
            XSSFSheet zonesheet = workbook.getSheet("Zones");
            XSSFSheet cfgsheet = workbook.getSheet("CFG");

            b = alisheet.getPhysicalNumberOfRows();
            d = zonesheet.getPhysicalNumberOfRows();
            f = cfgsheet.getPhysicalNumberOfRows();

            for (a = 0; a < b; a++) {

                XSSFRow rowa = alisheet.getRow(a);

                XSSFCell cellza = rowa.getCell((int) 0);
                XSSFCell cellzb = rowa.getCell((int) 1);

                if (cellza.getStringCellValue().equals("") || cellza.getStringCellValue() == null) {
                    break;
                }

                brocadefile.write("alicreate" + " " + "\"" + cellza.getStringCellValue().trim() + "\"" + ","
                        + " " + "\"" + cellzb.getStringCellValue().trim() + "\"");
                brocadefile.write("\n");

            }

            brocadefile.write("\n");
            brocadefile.write("\n");

            //Start of zone creation             

            for (c = 0; c < d; c++)

            {

                XSSFRow rowc = zonesheet.getRow(c);
                XSSFCell cellca = rowc.getCell((int) 0);
                XSSFCell cellcb = rowc.getCell((int) 1);
                XSSFCell cellcc = rowc.getCell((int) 2);

                if (cellca.getStringCellValue().equals("") || cellca.getStringCellValue() == null) {
                    break;
                }
                //zonecreate "zonemame", "member1; member2"

                brocadefile.write("zonecreate" + " " + "\"" + cellca.getStringCellValue().trim() + "\"" + ","
                        + " " + "\"" + cellcb.getStringCellValue().trim() + ";" + " "
                        + cellcc.getStringCellValue().trim() + "\"");
                brocadefile.write("\n");

            }

            brocadefile.write("\n");
            brocadefile.write("\n");

            XSSFRow rowc = cfgsheet.getRow(0);
            XSSFCell cellcfgcreateA = rowc.getCell((int) 0);
            XSSFCell cellcfgcreateB = rowc.getCell((int) 1);

            brocadefile.write("cfgcreate" + " " + "\"" + cellcfgcreateB.getStringCellValue().trim() + "\"" + ","
                    + " " + "\"" + cellcfgcreateA.getStringCellValue().trim() + "\"");
            brocadefile.write("\n");
            brocadefile.write("\n");

            for (e = 1; e < f; e++) {

                XSSFRow rowe = cfgsheet.getRow(e);
                XSSFCell cellea = rowe.getCell((int) 0);
                XSSFCell celleb = rowe.getCell((int) 1);

                if (cellea.getStringCellValue().equals("") || cellea.getStringCellValue() == null) {
                    break;
                }

                brocadefile.write("cfgadd" + " " + "\"" + celleb.getStringCellValue().trim() + "\"" + "," + " "
                        + "\"" + cellea.getStringCellValue().trim() + "\"");
                brocadefile.write("\n");
            }

            brocadefile.write("\n");
            brocadefile.write("\n");

            brocadefile.close();

        }

        //Start of Cisco Configuration
        else if (jRadioButton2.isSelected()) {

            //Cisco Configuration variables

            int g;
            int h;

            int i;
            int j;

            int k;
            int l;

            File file = new File(jTextField2.getText() + "\\" + jTextField3.getText());
            file.createNewFile();
            FileWriter ciscofile = new FileWriter(file);

            FileInputStream fileinputstream = new FileInputStream(jTextField1.getText());
            XSSFWorkbook ciscoworkbook = new XSSFWorkbook(fileinputstream);

            XSSFSheet alisheet = ciscoworkbook.getSheet("Aliases");
            XSSFSheet zonesheet = ciscoworkbook.getSheet("Zones");
            XSSFSheet cfgsheet = ciscoworkbook.getSheet("CFG");

            h = alisheet.getPhysicalNumberOfRows();
            j = zonesheet.getPhysicalNumberOfRows();
            l = cfgsheet.getPhysicalNumberOfRows();

            ciscofile.write("config t");
            ciscofile.write("\n");
            ciscofile.write("\n");

            //create aliases for Cisco switch

            for (g = 0; g < h; g++) {

                XSSFRow rowg = alisheet.getRow(g);
                XSSFCell cellga = rowg.getCell((int) 0);
                XSSFCell cellgb = rowg.getCell((int) 1);
                XSSFCell cellgc = rowg.getCell((int) 2);

                //config t
                //fcalias name CX4240_21_SPA vsan 3
                //member pwwn 50:06:01:60:46:e0:0f:ba
                //exit

                if (cellga.getStringCellValue().equals("") || cellga.getStringCellValue() == null) {
                    break;
                }

                ciscofile.write("fcalias name" + " " + cellga.getStringCellValue().trim() + " "
                        + cellgc.getStringCellValue().trim());
                ciscofile.write("\n");
                ciscofile.write("member pwwn" + " " + cellgb.getStringCellValue().trim());
                ciscofile.write("\n");
                ciscofile.write("exit");
                ciscofile.write("\n");
                ciscofile.write("\n");
            }

            ciscofile.write("\n");

            //create zones for cisco switch

            for (i = 0; i < j; i++) {

                XSSFRow rowi = zonesheet.getRow(i);
                XSSFCell cellia = rowi.getCell((int) 0);
                XSSFCell cellib = rowi.getCell((int) 1);
                XSSFCell cellic = rowi.getCell((int) 2);
                XSSFCell cellid = rowi.getCell((int) 3);

                //zone name U52P1_13 vsan 3 
                //member fcalias  CX4240_21_SPA
                //member fcalias  Unix1_52_P1
                //exit

                if (cellia.getStringCellValue().equals("") || cellia.getStringCellValue() == null) {
                    break;
                }

                ciscofile.write("zone name" + " " + cellia.getStringCellValue().trim() + " "
                        + cellid.getStringCellValue().trim());
                ciscofile.write("\n");
                ciscofile.write("member fcalias" + " " + cellib.getStringCellValue().trim());
                ciscofile.write("\n");
                ciscofile.write("member fcalias" + " " + cellic.getStringCellValue().trim());
                ciscofile.write("\n");
                ciscofile.write("exit");
                ciscofile.write("\n");
                ciscofile.write("\n");

            }

            ciscofile.write("\n");
            ciscofile.write("\n");

            //create zoneset and add it to a VSAN
            //                        
            XSSFRow rowmain = cfgsheet.getRow(1);
            XSSFCell cellcfgname = rowmain.getCell((int) 1);
            XSSFCell cellvsanname = rowmain.getCell((int) 2);

            //zoneset name main_config vsan 3 
            ciscofile.write("zoneset name" + " " + cellcfgname.getStringCellValue().trim() + " "
                    + cellvsanname.getStringCellValue().trim());
            ciscofile.write("\n");
            ciscofile.write("\n");

            for (k = 0; k < l; k++) {

                XSSFRow rowk = cfgsheet.getRow(k);
                XSSFCell cellka = rowk.getCell((int) 0);

                if (cellka.getStringCellValue().equals("") || cellka.getStringCellValue() == null) {
                    break;
                }

                //member L51P2_14  
                ciscofile.write("member" + " " + cellka.getStringCellValue().trim());
                ciscofile.write("\n");

            }

            ciscofile.write("\n");

            XSSFRow rowend = cfgsheet.getRow(1);
            XSSFCell cellendb = rowend.getCell((int) 1);
            XSSFCell cellendc = rowend.getCell((int) 2);

            //zoneset activate name main_config vsan 3 
            ciscofile.write("zoneset activate name" + " " + cellendb.getStringCellValue().trim() + " "
                    + cellendc.getStringCellValue().trim());
            ciscofile.write("\n");
            ciscofile.write("\n");
            ciscofile.close();
        }
    }

    catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}