Return-Path: X-Original-To: apmail-poi-user-archive@www.apache.org Delivered-To: apmail-poi-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C3A349299 for ; Mon, 5 Mar 2012 00:27:57 +0000 (UTC) Received: (qmail 83011 invoked by uid 500); 5 Mar 2012 00:27:57 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 82991 invoked by uid 500); 5 Mar 2012 00:27:57 -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 82980 invoked by uid 99); 5 Mar 2012 00:27:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 00:27:57 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of warren.c.tang@gmail.com designates 209.85.210.51 as permitted sender) Received: from [209.85.210.51] (HELO mail-pz0-f51.google.com) (209.85.210.51) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 00:27:52 +0000 Received: by dady9 with SMTP id y9so4075737dad.10 for ; Sun, 04 Mar 2012 16:27:31 -0800 (PST) Received-SPF: pass (google.com: domain of warren.c.tang@gmail.com designates 10.68.134.102 as permitted sender) client-ip=10.68.134.102; Authentication-Results: mr.google.com; spf=pass (google.com: domain of warren.c.tang@gmail.com designates 10.68.134.102 as permitted sender) smtp.mail=warren.c.tang@gmail.com; dkim=pass header.i=warren.c.tang@gmail.com Received: from mr.google.com ([10.68.134.102]) by 10.68.134.102 with SMTP id pj6mr41839873pbb.138.1330907251840 (num_hops = 1); Sun, 04 Mar 2012 16:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=KPU5AdyZtaAKKgiSTTPHprsZF4c9vYgkr//S7assv3k=; b=0JjPg62I9b7pNlevxy/9CrYK37bBBvhZYOCBw2qtRbDieu1q5iz5zamcnuIkYgBoMf 9QGHTw6CG37e3GnV0Ps6vQC93Lrav0c0WpIUrOWWvRP+XbV6z+jSlkPNHqeDq7KsTxVf T6EIGlm2r4Em1lTNW4XLikm1ZP4aagoVnN8lSE57xDV1R0wRpTczy60lHRh9XniDXBQv 4XPS+a+Rs7jg6aqBwrxebDD6+iRY4kmtSuJtJaVN6PTt5hhoKA/d24EUa4GsMI/pq2xm ZZV5Spz7z1l1aRRj8HE9U5zLZts3NZlNWvuzdMB+nKZ04USphhHK1Bn1lSrnbqfEEIC1 SAWg== MIME-Version: 1.0 Received: by 10.68.134.102 with SMTP id pj6mr35852319pbb.138.1330907251756; Sun, 04 Mar 2012 16:27:31 -0800 (PST) Received: by 10.68.228.10 with HTTP; Sun, 4 Mar 2012 16:27:31 -0800 (PST) Date: Mon, 5 Mar 2012 08:27:31 +0800 Message-ID: Subject: HSSF eventusermodel & field read/write problem. From: Warren Tang To: user@poi.apache.org Content-Type: multipart/alternative; boundary=e89a8ffbabadf84c8a04ba73fd80 X-Virus-Checked: Checked by ClamAV on apache.org --e89a8ffbabadf84c8a04ba73fd80 Content-Type: text/plain; charset=UTF-8 Hi, everybody I came across performance issue when reading large Excel97 files with usermodel. When the file size is over 15MB, the HSSFWorkbook's constructor never returns or returns with an OutOfMemoryError (GC overhead limit exceeded). So I've been trying to use eventusermodel to reduce the memory footprint, but I have problem to pertain the value of the modified fields. Below is the code. I need the modified value of an instance field (modifyMe); but the value is always 0 rather than 100 which is what I want. ----------------------------- HssfEventApiTest.java ---------------------------------------- import static org.junit.Assert.*; import java.io.IOException; import java.io.InputStream; import org.apache.poi.hssf.eventusermodel.HSSFEventFactory; import org.apache.poi.hssf.eventusermodel.HSSFListener; import org.apache.poi.hssf.eventusermodel.HSSFRequest; import org.apache.poi.hssf.record.EOFRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.junit.Test; import com.tangcs.zhc.server.ServerTestBase; public class HssfEventApiTest extends ServerTestBase implements HSSFListener { int modifyMe; // The instance field to be modified by the listener public void processRecord(Record record) { switch (record.getSid()) { case EOFRecord.sid: modifyMe = 100; //Modified here. System.out.println("End of file."); break; } } @Test public void testEventApi() throws IOException { InputStream fin = getResourceAsStream("xls/exam-results-min.xls"); POIFSFileSystem poifs = new POIFSFileSystem(fin); InputStream din = poifs.createDocumentInputStream("Workbook"); HSSFRequest req = new HSSFRequest(); req.addListenerForAllRecords(new HssfEventApiTest()); HSSFEventFactory factory = new HSSFEventFactory(); factory.processEvents(req, din); fin.close(); din.close(); System.out.println("modifyMe = " + modifyMe); assertEquals(100, modifyMe); //Fails here with actual == 0; // The stdout is: // End of file. // End of file. // modifyMe = 0 } } -- Regards, Warren Tang --e89a8ffbabadf84c8a04ba73fd80--