You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ambikesh Shukla <am...@gmail.com> on 2011/08/29 17:38:54 UTC

POI - Create sheet using Multithreading

Hi,

I need to create a workbook with multiple sheet [10 to 12 sheet with around
40k rows]. To improve performance i thought of using Multithreading
environment. 

I have 2 approach in mind :

1. I want to have N thread each writing to its own sheet. As I understand
POI doesn't support multithreading .

2. Create N different workbook in parallel and then merged these into one
workbook where each workbook becomes a sheet. POI don't have a good way of
copy a entire sheet with style.I don't know about performance.

Please share your experience.

Ambikesh

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


Re: POI - Create sheet using Multithreading

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
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.

Yours

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


Re: POI - Create sheet using Multithreading

Posted by Ambikesh Shukla <am...@gmail.com>.
Thanks Nick. Will Test it and post my findings.

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


Re: POI - Create sheet using Multithreading

Posted by Nick Burch <ni...@alfresco.com>.
On Wed, 31 Aug 2011, Ambikesh Shukla wrote:
> No one, huh? I need help...

You should only ever have one thread reading or writing to a given 
workbook

You're fine to have different threads work on different workbooks though

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: POI - Create sheet using Multithreading

Posted by Ambikesh Shukla <am...@gmail.com>.
No one, huh? I need help...

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