poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Beardsley <markbrd...@tiscali.co.uk>
Subject Re: POI - Create sheet using Multithreading
Date Thu, 01 Sep 2011 06:42:30 GMT
Should not really be doing this but here goes anyway.

I read this question and was more than a little intrigued as I think that
there is a way to accomplish what you want. The technique I might prototype
would work like this;

1. The main thread will create the workbook and any styles that are to be
applied to the cells of the sheets. These style object will be held in a
collection that supports multi-threaded acccess and you should reference
them by name - Hashtable would be the one to use I reckon and you can use
simple strings as the keys.
2. The main thread will then create a sheet and pass it off - along with a
reference to the the Hashtable and all of the sheets data - to another
thread for processing. You can create as many of these 'populating' threads
as you need to, but the basic premise is one for each sheet.
3. Once all of the populating threads have completed their work, the main
thread can save the workbook away.

I reckon this ought to work but you will have to find a way to pause the
main thread and make it wait until all of the poluating threads have
completed. It is important to complete any workbook level operations - style
creation is the main one that springs to mind - first as the workbook object
will not support, as Nick indicated, multi-threaded access. Also, I doubt
this would work if you are trying to use the streaming approach to building
the workbook, you will be limited to the usermodel approach through
HSSF/XSSF I think.


Mark B

View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-Create-sheet-using-Multithreading-tp4746558p4757295.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

View raw message