Android(安卓)解析excel文件
16lz
2022-01-26
- privatevoidparseExcel(){
- try{
- Workbookworkbook=null;
- InputStreamin=null;
- try{
- //in=this.getClassLoader().getResourceAsStream("CollMjr.xlsx");
- in=this.getAssets().open("CollMjr_1.xls");
- workbook=Workbook.getWorkbook(in);
- workbook.getNumberOfSheets()
- }catch(Exceptione){
- e.printStackTrace();
- thrownewException("filenotfound!");
- }
- Sheetsheet=workbook.getSheet(0);
- Cellcell=null;
- intcolumnCount=sheet.getColumns();
- introwCount=sheet.getRows();
- System.out.println("当前工作表的名字:"+sheet.getName());
- System.out.println("总行数:"+rowCount);
- System.out.println("总列数:"+columnCount);
- list=newArrayList<String>();
- for(inti=0;i<rowCount;i++){
- for(intj=0;j<columnCount;j++){
- //注意,这里的两个参数,第一个是表示列的,第二才表示行
- cell=sheet.getCell(j,i);
- Strings=sheet.getCell(columnCount-1,i).getContents();
- }
- }
- workbook.close();
- }catch(Exceptione){
- e.printStackTrace();
- }
- }
更多相关文章
- 在android里保存数据的三种形式(Saving Data)
- Android的AlertDialog的6种使用情景
- android 颜色(color)
- Android与(Servlet)服务器交互
- Android(安卓)实现一个http 带参数登录
- Android文件上传
- android之ArrayAdaper应用
- mybatisplus的坑 insert标签insert into select无参数问题的解决
- Python技巧匿名函数、回调函数和高阶函数