我想问问用下面这种方式创建的文档,为什么数据库打开会有错,提示格式错误。然后excel打开的话就只能在office2003上面运行,2007就会有格式错误,即使后缀改成xlsx。ppt的话每次打开名称都会变成演示文稿1.这是为什么啊?package test;import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;public class Test1 {
public static void main(String[] args) {
File filepath =new File("c:\\");
File file=new File(filepath,"test1.accdb");
//File file=new File(filepath,"test1.xls");
//File file=new File(filepath,"test1.ppt");
Runtime rn = Runtime.getRuntime();
try {
//FileOutputStream f=new FileOutputStream(file);
//f.write(12);
file.createNewFile();
file.setWritable(true);
//rn.exec("cmd.exe /c start c:\\test1.xlsx");
rn.exec("rundll32 url.dll FileProtocolHandler c:\\test1.accdb" );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;public class Test1 {
public static void main(String[] args) {
File filepath =new File("c:\\");
File file=new File(filepath,"test1.accdb");
//File file=new File(filepath,"test1.xls");
//File file=new File(filepath,"test1.ppt");
Runtime rn = Runtime.getRuntime();
try {
//FileOutputStream f=new FileOutputStream(file);
//f.write(12);
file.createNewFile();
file.setWritable(true);
//rn.exec("cmd.exe /c start c:\\test1.xlsx");
rn.exec("rundll32 url.dll FileProtocolHandler c:\\test1.accdb" );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
2007绝对可以的,不过是XSSFWorkbook是HSSFWorkbook的区别!使用XSSFWorkbook才能操作2007!
至于ppt,没做过!
我还以为你用POI呢,这么创建个TXT文件还差不多,起他文件你要用专用的jar包才能创建的!