POI Excel 使用

liuqiang 2021年03月16日 9次浏览

1.引入maven 依赖

<dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.10-FINAL</version>
</dependency>
<dependency>
     <groupId>org.apache.poi</groupId>
     <artifactId>poi-ooxml</artifactId>
     <version>3.10-FINAL</version>
</dependency>

  • 复制文文件
 // 复制文件
@SuppressWarnings("resource")
public static void copyField(File source, File dest) throws IOException {
	FileChannel input = null;
	FileChannel output = null;
	try {
		input = new FileInputStream(source).getChannel();
		output = new FileOutputStream(dest).getChannel();
		output.transferFrom(input, 0, input.size());
	} catch (Exception e) {
			// TODO Auto-generated catch block
		e.printStackTrace();
	} finally {
		input.close();
		output.close();
	   }
	}