NoClassDefFoundError: org/apache/commons/collections4/bidimap/TreeBidiMap
目前我报错的版本:
hamcrest-core-1.3
junit-4.12
ooxml-schemas-1.1.jar(网上说下载解决依赖,引入项目还是报错,项目确实没有这个类)
poi-3.17.jar
jdk1.8.0_131(jdk应该没关系)
problem中的报错:
The project was not built since its build path is incomplete. Cannot find the class file for org.apache.tools.ant.taskdefs.Typedef. Fix the build path then try building this project
junit中的报错:
java.lang.NoClassDefFoundError: org/apache/commons/collections4/bidimap/TreeBidiMap
at org.apache.poi.hpsf.Section.(Section.java:178)
at org.apache.poi.hpsf.MutableSection.(MutableSection.java:41)
at org.apache.poi.hpsf.PropertySet.init(PropertySet.java:494)
at org.apache.poi.hpsf.PropertySet.(PropertySet.java:196)
at org.apache.poi.hpsf.MutablePropertySet.(MutablePropertySet.java:44)
at org.apache.poi.hpsf.SpecialPropertySet.(SpecialPropertySet.java:47)
at org.apache.poi.hpsf.DocumentSummaryInformation.(DocumentSummaryInformation.java:99)
at org.apache.poi.hpsf.PropertySetFactory.create(PropertySetFactory.java:116)
at org.apache.poi.POIDocument.getPropertySet(POIDocument.java:236)
package TestCase;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFName;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
/**
* MainRemark TODO
* Modual TODO
* @author ***
* TestCaseTestExcellMaker.java
* 上午11:13:36
*
*/
public class TestExcellMaker {
@Before
public void setUp() throws Exception {
System.out.println("make excell file testcase");
}
@After
public void tearDown() throws Exception {
}
WebDriver driver;
@Test
public void test() throws IOException {
// ------
// 创建HSSFWorkbook对象
try {
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream("***.xls"));
HSSFSheet sheet = wb.getSheet("Sheet1");//得到表一
HSSFRow row = sheet.getRow(7); //得到表一 行7 下标为0
HSSFCell cell = row.getCell(2); //得到表一 列7 下标为0
System.out.println(cell.getStringCellValue());//输出C8的值
cell.setCellValue(""); //清空
System.out.println(cell.getStringCellValue());
cell.setCellValue("SeleN"+(new Date()).getTime()+""); //程序设置成功
System.out.println(cell.getStringCellValue()); //HPBCSele5958
// 输出Excel文件
FileOutputStream output = new FileOutputStream("***.xls");
wb.write(output);
output.close();
// wb.close();
} catch (Exception e) {
e.printStackTrace();
}
}
@Ignore
@Test
public void printXlsCoulums() throws FileNotFoundException, IOException{
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream("***.xls"));
List<HSSFName> allNames = wb.getAllNames();
HSSFSheet sheet = wb.getSheet("Sheet1");
for(int rowPositon=0;rowPositon<sheet.getPhysicalNumberOfRows();rowPositon++){
int cellTotal=sheet.getRow(rowPositon).getPhysicalNumberOfCells();
for(int cell=0;cell<cellTotal;cell++){
HSSFCell target = sheet.getRow(rowPositon).getCell(cell);
if(target != null){
System.out.println("Row:"+rowPositon+" / cell:"+cell+" "+target);
}
}
}
}
}