• 自动化测试随笔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 }
  • 相关阅读:
    python:(类)私有
    Python:多继承时的继承顺序
    python基础:继承
    年终总结
    cocos版本说明
    WPF学习系列 游戏-选张图片做成9宫格拼图
    SmartAssembly使用失败记录
    WPF学习系列 绘制旋转的立方体
    自适应布局思路
    webfrom 总结
  • 原文地址:https://www.cnblogs.com/by170628/p/7094842.html
Copyright © 2020-2023  润新知