添加依赖项
这里直接给出Maven配置文件
junit
junit
3.8.1
test
dom4j
dom4j
1.6.1
org.apache.poi
poi-ooxml-schemas
3.9
org.apache.xmlbeans
xmlbeans
2.3.0
org.apache.poi
poi-ooxml
3.9
org.apache.poi
poi
3.9
读取excel
static void Write(String path) throws InvalidFormatException, IOException
{
FileInputStream file = new FileInputStream(new File(path));
Workbook workbook = WorkbookFactory.create(file);//读取excel文件
Sheet sheet = workbook.getSheetAt(0);//获取第一个sheet页
//遍历行
Iterator rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
//遍历列
Iterator cellIterator = row.cellIterator();
while (cellIterator.hasNex