• 读取execl数据


    public static void main(String[] args) throws IOException {

        FileInputStream fileInput = new FileInputStream("C:\Users\DELL4\Desktop\567.xlsx");//创建文件输入流
        XSSFWorkbook wb = new XSSFWorkbook(fileInput);//由输入流文件得到工作簿对象
        XSSFSheet sheet = wb.getSheetAt(0);//获取第一个sheet
        int lastRowNum = sheet.getLastRowNum(); //获取表格内容的最后一行的行数
    
        //rowBegin代表要开始读取的行号,下面这个循环的作用是读取每一行内容
        for (int i = 1; i <= lastRowNum; ++i) {
            XSSFRow row = sheet.getRow(i);//获取每一行
            int columnNum = row.getLastCellNum();//获取每一行的最后一列的列号,即总列数
            for (int j = 1; j < columnNum; ++j) {
                XSSFCell cell = row.getCell(j);//获取每个单元格
                if (CellType.NUMERIC.equals(cell.getCellTypeEnum())) {
                    System.out.printf("%.0f	", cell.getNumericCellValue());
                } else {
                    System.out.printf("%s	", cell.getStringCellValue());
                }
            }
            System.out.println();
        }
        wb.close();
        fileInput.close();
    
    }
  • 相关阅读:
    Ubuntu分区挂载
    YOLOv3:Demo needs OpenCV for webcam images
    tf.strided_slice函数
    numpy:np.random.seed()
    python:split()函数
    python:set() 函数
    python:zip() 函数
    python:enumerate 函数
    电脑无法上网,DNS出现fec0:0:0:ffff::1%1问题
    python:map 函数
  • 原文地址:https://www.cnblogs.com/cwshuo/p/14798906.html
Copyright © 2020-2023  润新知