首页 > 其他 > 详细

自动化测试随笔2

时间:2017-06-29 16:22:19      阅读:254      评论:0      收藏:0      [点我收藏+]
读取出了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 }

 

自动化测试随笔2

原文:http://www.cnblogs.com/by170628/p/7094842.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!