You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Cheenu <ch...@users.sourceforge.net> on 2006/08/24 23:35:08 UTC

how to combine two workbooks

I have two HSSFWorkbook objects, each having one HSSFSheet.
I want to create a third HSSFWorkbook containing two sheets (one from each
of the workbooks).

I could not find a way to do this from the API - am I missing something.

A code snippet to explain the same:

HSSFWorkbook hrWorkBook = getDepartmentDetails("HR");
HSSFWorkbook financeWorkBook = getDepartmentDetails("Finance");

HSSFWorkbook finalWorkBook = ???;   // I want to somehow create this
finalWorkBook with the one sheet from the hr and finance workbook

Thanks
Cheenu

Re: how to combine two workbooks

Posted by Sebastian Frehmel <uh...@stud.uni-karlsruhe.de>.
Wow!
THat's a great class!
I'll certainly give a try in the future! Thanks Cheene for searching :-)


Cheenu schrieb:
> Yaahhhoooooooooo!!
>
> Found a perfectly working copySheet code for POI - atleast for my needs.
> http://jxls.cvs.sourceforge.net/jxls/jxls/src/java/org/jxls/util/Util.java?view=markup 
>
>
> method copySheets.
>
> Nice job jXLS contributors, in this case Leonid Vysochyn.
> Thanks.
>
> On 8/25/06, Cheenu < sm88il-noreply@yahoo.com> wrote:
>>
>> Something like the cloneSheet method cannot be used, as it seems like 
>> the
>> BIFF fileformat is more complicated than that.
>> I think it would be more safer and API compliant to do something like 
>> the
>> attached code.
>> But, it is far from complete - one main problem is that there is no 
>> way to
>> copy over Workbook styles.
>> Seems like in BIFF all styles are kept at workbook level and not at 
>> sheet
>> level.
>>
>>
>> On 8/25/06, Sebastian Frehmel < uhbdz@stud.uni-karlsruhe.de> wrote:
>> >
>> > I'm sorry, but I dont't think I will be able to post code here within
>> > the next 3 weeks because I've got other, way more important stuff 
>> to do.
>> > But what came in to my mind is the cloneSheet method.
>> > This method is used to clone a sheet within a workbook But if someone
>> > looked into the source code a little deeper, this someone might 
>> probably
>> >
>> > find a way to return the sheet to another workbook.
>> > Do you have time and knowledge for this?
>> >
>> > Cheenu schrieb:
>> > > Sebastian,
>> > > Seems like there is no way to do this than copying cell by cell.
>> > > JExcelApi does not provide a way as well -
>> > > http://groups.yahoo.com/group/JExcelApi/message/8069
>> > >
>> > > Can we exchange code to get the best possible way to do this?
>> > > I will code something up and post it here.
>> > >
>> > > Cheenu
>> > >
>> > > On 8/24/06, Sebastian Frehmel <uhbdz@stud.uni-karlsruhe.de > wrote:
>> > >>
>> > >> This is a feature I miss, too.
>> > >> Just the possibility to say something like:
>> > >> wb.addSheet(HSSFSheet a)
>> > >>
>> > >> Until now I had to copy all cells manually....
>> > >> Does anyone know how?
>> > >>
>> > >> Cheenu schrieb:
>> > >> > I have two HSSFWorkbook objects, each having one HSSFSheet.
>> > >> > I want to create a third HSSFWorkbook containing two sheets (one
>> > from
>> > >> > each
>> > >> > of the workbooks).
>> > >> >
>> > >> > I could not find a way to do this from the API - am I missing
>> > >> something.
>> > >> >
>> > >> > A code snippet to explain the same:
>> > >> >
>> > >> > HSSFWorkbook hrWorkBook = getDepartmentDetails("HR");
>> > >> > HSSFWorkbook financeWorkBook = getDepartmentDetails("Finance");
>> > >> >
>> > >> > HSSFWorkbook finalWorkBook = ???;   // I want to somehow create
>> > this
>> > >> > finalWorkBook with the one sheet from the hr and finance workbook
>> > >> >
>> > >> > Thanks
>> > >> > Cheenu
>> > >>
>> > >> 
>> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>> > >> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>> > >> The Apache Jakarta Poi Project:   http://jakarta.apache.org/poi/
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>> > Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>> > The Apache Jakarta Poi Project:   http://jakarta.apache.org/poi/
>> >
>> >


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: how to combine two workbooks

Posted by Cheenu <sm...@yahoo.com>.
Yaahhhoooooooooo!!

Found a perfectly working copySheet code for POI - atleast for my needs.
http://jxls.cvs.sourceforge.net/jxls/jxls/src/java/org/jxls/util/Util.java?view=markup

method copySheets.

Nice job jXLS contributors, in this case Leonid Vysochyn.
Thanks.

On 8/25/06, Cheenu < sm88il-noreply@yahoo.com> wrote:
>
> Something like the cloneSheet method cannot be used, as it seems like the
> BIFF fileformat is more complicated than that.
> I think it would be more safer and API compliant to do something like the
> attached code.
> But, it is far from complete - one main problem is that there is no way to
> copy over Workbook styles.
> Seems like in BIFF all styles are kept at workbook level and not at sheet
> level.
>
>
> On 8/25/06, Sebastian Frehmel < uhbdz@stud.uni-karlsruhe.de> wrote:
> >
> > I'm sorry, but I dont't think I will be able to post code here within
> > the next 3 weeks because I've got other, way more important stuff to do.
> > But what came in to my mind is the cloneSheet method.
> > This method is used to clone a sheet within a workbook But if someone
> > looked into the source code a little deeper, this someone might probably
> >
> > find a way to return the sheet to another workbook.
> > Do you have time and knowledge for this?
> >
> > Cheenu schrieb:
> > > Sebastian,
> > > Seems like there is no way to do this than copying cell by cell.
> > > JExcelApi does not provide a way as well -
> > > http://groups.yahoo.com/group/JExcelApi/message/8069
> > >
> > > Can we exchange code to get the best possible way to do this?
> > > I will code something up and post it here.
> > >
> > > Cheenu
> > >
> > > On 8/24/06, Sebastian Frehmel <uhbdz@stud.uni-karlsruhe.de > wrote:
> > >>
> > >> This is a feature I miss, too.
> > >> Just the possibility to say something like:
> > >> wb.addSheet(HSSFSheet a)
> > >>
> > >> Until now I had to copy all cells manually....
> > >> Does anyone know how?
> > >>
> > >> Cheenu schrieb:
> > >> > I have two HSSFWorkbook objects, each having one HSSFSheet.
> > >> > I want to create a third HSSFWorkbook containing two sheets (one
> > from
> > >> > each
> > >> > of the workbooks).
> > >> >
> > >> > I could not find a way to do this from the API - am I missing
> > >> something.
> > >> >
> > >> > A code snippet to explain the same:
> > >> >
> > >> > HSSFWorkbook hrWorkBook = getDepartmentDetails("HR");
> > >> > HSSFWorkbook financeWorkBook = getDepartmentDetails("Finance");
> > >> >
> > >> > HSSFWorkbook finalWorkBook = ???;   // I want to somehow create
> > this
> > >> > finalWorkBook with the one sheet from the hr and finance workbook
> > >> >
> > >> > Thanks
> > >> > Cheenu
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > >> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> > >> The Apache Jakarta Poi Project:   http://jakarta.apache.org/poi/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> > The Apache Jakarta Poi Project:   http://jakarta.apache.org/poi/
> >
> >
>
>

Re: how to combine two workbooks

Posted by Cheenu <sm...@yahoo.com>.
Something like the cloneSheet method cannot be used, as it seems like the
BIFF fileformat is more complicated than that.
I think it would be more safer and API compliant to do something like the
attached code.
But, it is far from complete - one main problem is that there is no way to
copy over Workbook styles.
Seems like in BIFF all styles are kept at workbook level and not at sheet
level.

On 8/25/06, Sebastian Frehmel <uh...@stud.uni-karlsruhe.de> wrote:
>
> I'm sorry, but I dont't think I will be able to post code here within
> the next 3 weeks because I've got other, way more important stuff to do.
> But what came in to my mind is the cloneSheet method.
> This method is used to clone a sheet within a workbook But if someone
> looked into the source code a little deeper, this someone might probably
> find a way to return the sheet to another workbook.
> Do you have time and knowledge for this?
>
> Cheenu schrieb:
> > Sebastian,
> > Seems like there is no way to do this than copying cell by cell.
> > JExcelApi does not provide a way as well -
> > http://groups.yahoo.com/group/JExcelApi/message/8069
> >
> > Can we exchange code to get the best possible way to do this?
> > I will code something up and post it here.
> >
> > Cheenu
> >
> > On 8/24/06, Sebastian Frehmel <uh...@stud.uni-karlsruhe.de> wrote:
> >>
> >> This is a feature I miss, too.
> >> Just the possibility to say something like:
> >> wb.addSheet(HSSFSheet a)
> >>
> >> Until now I had to copy all cells manually....
> >> Does anyone know how?
> >>
> >> Cheenu schrieb:
> >> > I have two HSSFWorkbook objects, each having one HSSFSheet.
> >> > I want to create a third HSSFWorkbook containing two sheets (one from
> >> > each
> >> > of the workbooks).
> >> >
> >> > I could not find a way to do this from the API - am I missing
> >> something.
> >> >
> >> > A code snippet to explain the same:
> >> >
> >> > HSSFWorkbook hrWorkBook = getDepartmentDetails("HR");
> >> > HSSFWorkbook financeWorkBook = getDepartmentDetails("Finance");
> >> >
> >> > HSSFWorkbook finalWorkBook = ???;   // I want to somehow create this
> >> > finalWorkBook with the one sheet from the hr and finance workbook
> >> >
> >> > Thanks
> >> > Cheenu
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> >> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> >> The Apache Jakarta Poi Project:   http://jakarta.apache.org/poi/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>
>

Re: how to combine two workbooks

Posted by Sebastian Frehmel <uh...@stud.uni-karlsruhe.de>.
I'm sorry, but I dont't think I will be able to post code here within 
the next 3 weeks because I've got other, way more important stuff to do.
But what came in to my mind is the cloneSheet method.
This method is used to clone a sheet within a workbook But if someone 
looked into the source code a little deeper, this someone might probably 
find a way to return the sheet to another workbook.
Do you have time and knowledge for this?

Cheenu schrieb:
> Sebastian,
> Seems like there is no way to do this than copying cell by cell.
> JExcelApi does not provide a way as well -
> http://groups.yahoo.com/group/JExcelApi/message/8069
>
> Can we exchange code to get the best possible way to do this?
> I will code something up and post it here.
>
> Cheenu
>
> On 8/24/06, Sebastian Frehmel <uh...@stud.uni-karlsruhe.de> wrote:
>>
>> This is a feature I miss, too.
>> Just the possibility to say something like:
>> wb.addSheet(HSSFSheet a)
>>
>> Until now I had to copy all cells manually....
>> Does anyone know how?
>>
>> Cheenu schrieb:
>> > I have two HSSFWorkbook objects, each having one HSSFSheet.
>> > I want to create a third HSSFWorkbook containing two sheets (one from
>> > each
>> > of the workbooks).
>> >
>> > I could not find a way to do this from the API - am I missing 
>> something.
>> >
>> > A code snippet to explain the same:
>> >
>> > HSSFWorkbook hrWorkBook = getDepartmentDetails("HR");
>> > HSSFWorkbook financeWorkBook = getDepartmentDetails("Finance");
>> >
>> > HSSFWorkbook finalWorkBook = ???;   // I want to somehow create this
>> > finalWorkBook with the one sheet from the hr and finance workbook
>> >
>> > Thanks
>> > Cheenu
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>> The Apache Jakarta Poi Project:   http://jakarta.apache.org/poi/


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: how to combine two workbooks

Posted by Cheenu <sm...@yahoo.com>.
Sebastian,
Seems like there is no way to do this than copying cell by cell.
JExcelApi does not provide a way as well -
http://groups.yahoo.com/group/JExcelApi/message/8069

Can we exchange code to get the best possible way to do this?
I will code something up and post it here.

Cheenu

On 8/24/06, Sebastian Frehmel <uh...@stud.uni-karlsruhe.de> wrote:
>
> This is a feature I miss, too.
> Just the possibility to say something like:
> wb.addSheet(HSSFSheet a)
>
> Until now I had to copy all cells manually....
> Does anyone know how?
>
> Cheenu schrieb:
> > I have two HSSFWorkbook objects, each having one HSSFSheet.
> > I want to create a third HSSFWorkbook containing two sheets (one from
> > each
> > of the workbooks).
> >
> > I could not find a way to do this from the API - am I missing something.
> >
> > A code snippet to explain the same:
> >
> > HSSFWorkbook hrWorkBook = getDepartmentDetails("HR");
> > HSSFWorkbook financeWorkBook = getDepartmentDetails("Finance");
> >
> > HSSFWorkbook finalWorkBook = ???;   // I want to somehow create this
> > finalWorkBook with the one sheet from the hr and finance workbook
> >
> > Thanks
> > Cheenu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:   http://jakarta.apache.org/poi/
>
>

Re: how to combine two workbooks

Posted by Sebastian Frehmel <uh...@stud.uni-karlsruhe.de>.
This is a feature I miss, too.
Just the possibility to say something like:
wb.addSheet(HSSFSheet a)

Until now I had to copy all cells manually....
Does anyone know how?

Cheenu schrieb:
> I have two HSSFWorkbook objects, each having one HSSFSheet.
> I want to create a third HSSFWorkbook containing two sheets (one from 
> each
> of the workbooks).
>
> I could not find a way to do this from the API - am I missing something.
>
> A code snippet to explain the same:
>
> HSSFWorkbook hrWorkBook = getDepartmentDetails("HR");
> HSSFWorkbook financeWorkBook = getDepartmentDetails("Finance");
>
> HSSFWorkbook finalWorkBook = ???;   // I want to somehow create this
> finalWorkBook with the one sheet from the hr and finance workbook
>
> Thanks
> Cheenu

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/