问题描述
我有一个要求,我必须将具有多个工作表的单个excel文件拆分为不同的excel文件
例如一个工作簿中有6个标签,我想从这个工作簿中将6个标签分离成6个不同的文件
我在下面尝试过此操作,但这只是将所有标签复制到具有标签名称的多个文件中
private static void copyFileUsingJava7Files(File source,File dest) throws IOException {
Files.copy(source.toPath(),dest.toPath());
}
public static void main(String args[]) throws IOException {
Workbook oldWB = new XSSFWorkbook(new FileInputStream("source file path"));
int k=oldWB.getNumberOfSheets();
for(int j=0;j<=k-1;j++)
{
String af = oldWB.getSheetName(j);
System.out.println(oldWB.getSheetName(j));
File source = new File("source file path");
File dest = new File("C:\\Automation-Scripts\\aws\\"+af+".xlsx");
copyFileUsingJava7Files(source,dest);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)