【问题标题】:How to read/write excel checkbox status in java [closed]如何在java中读取/写入excel复选框状态[关闭]
【发布时间】:2014-02-15 05:29:25
【问题描述】:

如何从excel2010 获取无线电值(true or false)?在java中,谢谢!

【问题讨论】:

    标签: java excel radio


    【解决方案1】:

    首先您必须下载Apache POI 库。然后你可以借助下面给出的代码来实现你想要的。

    FileInputStream file = new FileInputStream(new File("d:/file.xls"));
    
    //Get the workbook instance for XLS file 
    HSSFWorkbook workbook = new HSSFWorkbook(file);
    
    //Get first sheet from the workbook
    HSSFSheet sheet = workbook.getSheetAt(0);
    
    //Iterate through each rows from first sheet
    Iterator<Row> rowIterator = sheet.iterator();
    while(rowIterator.hasNext()) {
        Row row = rowIterator.next();
    
        //For each row, iterate through each columns
        Iterator<Cell> cellIterator = row.cellIterator();
        while(cellIterator.hasNext()) {
    
            Cell cell = cellIterator.next();
    
            switch(cell.getCellType()) {
                case Cell.CELL_TYPE_BOOLEAN:
                    System.out.print(cell.getBooleanCellValue() + "\t\t");
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    System.out.print(cell.getNumericCellValue() + "\t\t");
                    break;
                case Cell.CELL_TYPE_STRING:
                    System.out.print(cell.getStringCellValue() + "\t\t");
                    break;
            }
        }
        System.out.println("");
    }
    

    查看link 了解更多信息。

    【讨论】:

    • 它读取除带有复选框表单按钮的单元格之外的所有单元格。
    猜你喜欢
    • 2013-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    相关资源
    最近更新 更多