JAVAはPOIに基づいてExcelを導入します。
4359 ワード
ダウンロード
https://download.csdn.net/download/qq_39706570/12524634
分析
https://download.csdn.net/download/qq_39706570/12524634
分析
1、 Excel , ;
2、 , ;
3、 List
呼び出しListケース/**
* @author SargerasWang
*/
package com.sargeraswang.util.ExcelUtil;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
/**
* List
呼び出しListケースpackage com.sargeraswang.util.ExcelUtil;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
public class TestExportBean {
@Test
public void exportXls() throws IOException {
// Map Map ExcelCell index
Map map = new LinkedHashMap<>();
// @ExcelCell index 。
map.put("name"," ");
map.put("age"," ");
map.put("className"," ");
map.put("createTime"," ");
Collection
導入事例を呼び出します/**
* @author SargerasWang
*/
package com.sargeraswang.util.ExcelUtil;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.Map;
/**
* Excel 97/2003
*/
public class TestImportExcel {
@Test
public void importXls() throws FileNotFoundException {
File f=new File("C:\\Users\\Administrator\\Desktop\\a.xlsx");
InputStream inputStream= new FileInputStream(f);
ExcelLogs logs =new ExcelLogs();
Collection importExcel ;
try {
importExcel = ExcelUtil.importExcel(Map.class, inputStream, "yyyy/MM/dd HH:mm:ss", logs , 0);
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
for(Map m : importExcel){
System.out.println(m);
}
}
}