Android(安卓)解析excel文件
16lz
2021-12-04
- private void parseExcel(){
- try {
- Workbook workbook = null;
- InputStream in = null;
- try {
- // in = this.getClassLoader().getResourceAsStream("CollMjr.xlsx");
- in = this.getAssets().open("CollMjr_1.xls");
- workbook = Workbook.getWorkbook(in);
- workbook.getNumberOfSheets()
- } catch (Exception e) {
- e.printStackTrace();
- throw new Exception("file not found!");
- }
- Sheet sheet = workbook.getSheet(0);
- Cell cell = null;
- int columnCount = sheet.getColumns();
- int rowCount = sheet.getRows();
- System.out.println("当前工作表的名字:" + sheet.getName());
- System.out.println("总行数:" + rowCount);
- System.out.println("总列数:" + columnCount);
- list = new ArrayList
(); - for (int i = 0; i < rowCount; i++) {
- for (int j = 0; j < columnCount; j++) {
- // 注意,这里的两个参数,第一个是表示列的,第二才表示行
- cell = sheet.getCell(j, i);
- String s = sheet.getCell(columnCount-1, i).getContents();
- }
- }
- workbook.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
更多相关文章
- Monkey
- 2011.07.18——— android AlphaBitmap
- 2011.07.18——— android AlphaBitmap
- android TextView 走马灯效果
- Android(安卓)中文 API (100) ―― ScrollView
- Android笔记--短信与拨号
- android 自定义组件圆形边框
- android中的震动
- android 设置textview 边框