Return-Path: Delivered-To: apmail-poi-user-archive@www.apache.org Received: (qmail 78792 invoked from network); 17 Sep 2009 14:39:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Sep 2009 14:39:17 -0000 Received: (qmail 25199 invoked by uid 500); 17 Sep 2009 14:39:16 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 25167 invoked by uid 500); 17 Sep 2009 14:39:16 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Received: (qmail 25157 invoked by uid 99); 17 Sep 2009 14:39:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Sep 2009 14:39:16 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Sep 2009 14:39:05 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1MoI8C-0004Ta-OD for user@poi.apache.org; Thu, 17 Sep 2009 07:38:44 -0700 Message-ID: <25491916.post@talk.nabble.com> Date: Thu, 17 Sep 2009 07:38:44 -0700 (PDT) From: "Lingjiao.Chen" To: user@poi.apache.org Subject: Re: Converting an XSSF model to an HSSF model In-Reply-To: <24122575.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: lingjiao.chen@cloudnovations.com References: <24113483.post@talk.nabble.com> <24122575.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Mark, We are somewhat similar in situation. The second approach you purposed sounds promising. Could you please forward the classes you've mentioned? Thanks. MSB wrote: > > Morning Greg, > > Whilst I have had a very good look through the javadocs, I am by no means > an expert so treat what I have to say with caution please. Having said > that, I do not think there is an existing method within the POI API that > you can use to transcode (convert) between an OpenXML file and a binary > (BIFF8) file. You could use POI to create such a method however by > stepping through the input workbook - an XSSFWorkbook in your case I would > guess - and creating analogous objects within an HSSFWorkbook for > everything you find there; if your workbooks are fairly simple then this > could be the way to go but if they are more complex then that could > involve some work. > > You do have other options however and the best one - at least to my mind - > would be OLE/COM. If you are working on a stand alone PC and have Office > 2007 installed on that machine, then you can use OLE to control an > instance of the Excel application and 'ask' it to convert the files for > you. There are plenty of libraries you could use to accomplish this task > but the only one I have any experience with is the ole32 package of the > Standard Widget Toolkit. The SWT is part of the Eclispe IDE, can be > downloaded separately and I have found it quite easy to work with. In > fact, if you choose to go this way, let me know and I will forward a > couple of classes that will allow you to use Excel to convert between > different file types. You do need to be aware however that this approach > does have problems; it is hard to trap and handle errors for example. > Still, I think this is the beast approach as you are using the application > created by the authors of the file formats involved. > > A slightly modified version of this would be to use Excel macros to > perform the conversions for you. It is possible to create a VBA macro that > would open a file and save it in a different format. If you have lots of > files to process, you could enter their names into the cells of a > worksheet and have the macro iterate through the cells opening each file > and then re-saving it in the appropriate format. Of course, this also > depeneds upon your having access to Office 2007. I have never done this > but it would be a simple task to use the macro recorder feature to > prototype the code and then simply tweak it to do what you require. > > The third option is OpenOffice. It uses filters to handle different file > types and by specifying the filter the application should use, it is > possible to convert between different file types. Again, it is possible to > control OpenOffice from Java code through a clearly defined - though > complex - interface. Using this technique again depened upon having > OpenOffice and it's associated SDK installed. Furthermore, I would advise > you to use either Eclipse or Netbeans as you IDE as both have a plugin > that make developing UNO client applications far easier. As with OLE, I > have code that I can let you have to accomplish this task. In my > experience, OpenOffice is fine with all but the more complex spreadsheet > files; for example, it has problems handling OpenXML spreadsheets that > contain embedded objects and I am certain there will be other limitations. > My only concern with this technique is that I have not yet been able to > find the specific filter for opening and openXML based workbook even > thgouhg I know that Calc can read such files. > > Finally, there are on-line conversion services available. This would be, > to my mind, a last resort as you would have to send your files across the > internet to a third party; the security implications are obvious. > > Hope this helps. > > Yours > > Mark B > > > Greg Inns wrote: >> >> Use Case: read in an XLSX file, convert it, and write out an XLS file. >> >> It looks like both the HSSFWorkbook and the XSSFWorkbook both implement >> the SS Workbook interface, but that's where it ends. In my mind, it make >> sense to be able to construct a HSSFWorkbook from an XSSFWorkbook and >> visa versa, although I would expect there might be some lost information >> in former case. >> >> Am I missing something in the API documentation? Or something else? >> >> >> > > -- View this message in context: http://www.nabble.com/Converting-an-XSSF-model-to-an-HSSF-model-tp24113483p25491916.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org