zoukankan      html  css  js  c++  java
  • 自动化测试随笔2

    读取出了excel后 把值拼成list

    1
    package Common; 2 3 import java.io.FileInputStream; 4 import java.io.InputStream; 5 import java.util.ArrayList; 6 import java.util.List; 7 8 import org.testng.annotations.Test; 9 10 import jxl.Cell; 11 import jxl.Sheet; 12 import jxl.Workbook; 13 14 public class excel { 15 16 public static List<List<String>> addexcel() throws Throwable{ 17 jxl.Workbook readwb = null; 18 InputStream instream = new FileInputStream("c:/萝卜丁.xls"); 19 readwb = Workbook.getWorkbook(instream); 20 Sheet readsheet = readwb.getSheet(0); 21 int rsColumns = readsheet.getColumns(); 22 int rsRows = readsheet.getRows(); 23 List<List<String>> list2 = new ArrayList<List<String>>(); 24 25 for(int column = 1;column < rsColumns;column ++) 26 { 27 ArrayList<String> list1=new ArrayList<String>(); 28 29 for(int row = 1;row < rsRows;row ++) 30 { 31 Cell cell = readsheet.getCell(column, row); 32 String content = cell.getContents(); 33 34 if(content == null|| content.isEmpty()) 35 { 36 continue; 37 } 38 39 if(content!=null){ 40 list1.add(content); 41 } 42 43 } 44 45 list2.add(list1); 46 } 47 System.out.println(list2); 48 return list2; 49 } 50 51 52 @Test 53 public void readexcel() throws Throwable { 54 55 addexcel(); 56 } 57 58 59 }
  • 相关阅读:
    web基础要点记录
    前端一些干货
    正则表达式手册
    JQuery实现旋转轮播图
    JQuery模拟常见的拖拽验证
    electron应用以管理员权限启动
    原生JS模拟百度搜索关键字与跳转
    关于Application的使用
    Android事件分发机制(相关文章)
    (转)Activity的四种launchMode
  • 原文地址:https://www.cnblogs.com/by170628/p/7094842.html
Copyright © 2011-2022 走看看