public static void main(String []args)throws IOException
{
//FileInputStream file = new FileInputStream(new File("test.xlsx"));
FileInputStream fis = new FileInputStream(new File("test.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook (fis);
XSSFSheet sheet = workbook.getSheetAt(0);
//Create First Row
XSSFRow row1 = sheet.createRow(0);
XSSFCell r1c1 = row1.createCell(0);
r1c1.setCellValue("Emd Id");
fis.close();
try
{
FileOutputStream fos =new FileOutputStream(new File("test.xlsx"));
workbook.write(fos);
fos.close();
System.out.println("Done");
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
错误是:
Exception in thread "main" java.io.FileNotFoundException: test.xlsx (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at excel.CxssfWe1.main(CxssfWe1.java:25)
答案 0 :(得分:0)
您正在尝试读取行中不存在的文件
FileInputStream fis = new FileInputStream(new File("test.xlsx"));
这正是错误消息所说的:“(系统找不到指定的文件)”