File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using HSSFWorkbook to copy excel file

 
daphna deutsch
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The program bellow creates a copy of an excel file.
I am using the HSSFWorkbook object because i need to change information on the new file.
The problem is that an object that was created in the original file lost its focus on the copied file.
For example, I add a power point object in the original file, and in the copied file i can see the object, but clicking on it reveals the error message "cannot start the source application for this object"

Does anyone know this problem?



FileInputStream fileIn = null;
FileOutputStream fileOut = null;
try{
String xlsFileName = "D:/i3/32_100006.xls";
String xlsFileNameCopy = "D:/i3/Copy32_100006.xls";
fileIn = new FileInputStream(xlsFileName);
POIFSFileSystem fs = new POIFSFileSystem(fileIn);
HSSFWorkbook wb = new HSSFWorkbook(fs);

/* change the file*/

fileOut = new FileOutputStream(xlsFileNameCopy);
wb.write(fileOut);
fileOut.close();
}
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That may be a limitation of POIFS (the document access routines POI uses).

Have you tried copying the file first by other means, and then using POI to change the fresh copy?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic