>On Wed, 13 Feb 2002 11:19:04 0530 "Kini, Nagraj (CORP, GEITC)" <[EMAIL PROTECTED]> wrote. >Hi, > Is there a way to read a sheet direclty and merger it with another file.
Not currently without manually copying everything. I agree this should be added. This isn't the first time its been requested. Glen, are you interested in doing this? If not, I'll add it to my list of things to do. >This is what i am trying to do. But the handle for the work sheet doesnt get One thing I should point out, this would not work (as you coded it) even if it were added. You assign s to s1 which would only copy the reference not add it somehow to the Workbook object's collection of sheets. We'll need a HSSFWorkbook.addSheet(HSSFSheet sheet) method to support this. The simple assignment of one reference to another wouldn't quite cut it. -Andy >transfered. >public class readxlssheet { > public static void main(String arv[]){ > try{ > FileInputStream in = new >FileInputStream("PG00073-AU7189-OMPA.xls"); > Filesystem fs = new Filesystem(in); > HSSFWorkbook h = new HSSFWorkbook(fs); > HSSFSheet s = h.getSheet("BOM FORM"); > HSSFRow r = s.getRow(0); > HSSFCell c = r.getCell((short)0); > System.out.println(c.getStringCellValue()); > HSSFWorkbook h1 = new HSSFWorkbook(); > HSSFSheet s1 = h1.createSheet("new"); > s1 = s; > FileOutputStream out = new FileOutputStream ("new.xls"); > h1.write(out); > }catch(Exception ex){ > System.out.println("Error" ex.getMessage()); > } > } >} > >Any other way to do it? >Thanks, >Nagraj. > > >"THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE >ADDRESSEE and may contain confidential and privileged information. >If the reader of this message is not the intended recipient, >you are notified that any dissemination, distribution or copy of this >communication is strictly Prohibited. >If you have received this message by error, please notify us >immediately, return the original mail to the sender and delete the >message from your system." > >