We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Combine multiple sheets into a single one using Aspose.Cells for Java

Hi,

I am creating multiple sheets in a workbook (Each sheet contains data as well as charts) using aspose cells . Is it possible to combine all the sheets in that workbook into a single sheet? Please help.

Thanks,
Geetha

Hi,

Yes, it is possible. Please see the code below, it combines the first xls file with another xls file.

Please see the source and output workbooks.

Java


String pathFirst = “f:\downloads\first.xls” ;

String pathSecond = “f:\downloads\second.xls” ;


Workbook firstWorkbook = new Workbook();

firstWorkbook.open(pathFirst);


Workbook secondWorkbook = new Workbook();

secondWorkbook.open(pathSecond);

firstWorkbook.combine(secondWorkbook);

firstWorkbook.save(“f:\downloads\combined.xls”);

Thanks. This sample code combines two xls workbook and saves it as a new workbook.

Out requirement is in one xls workbook we have multiple sheets with charts and data. We need to combine these multiple sheets in the same workbook into a single sheet. Will that be possible?

Hi,

I think, then you should try copying rows from second source sheet into the end of first source sheet.

You can see copying rows example from this post: 298463

Hi,

Also, check some more documents for your further reference:
https://docs.aspose.com/display/cellsnet/Copy+Range+Data+with+Style
https://docs.aspose.com/display/cellsnet/Copy+GridWeb+Rows+and+Columns
https://docs.aspose.com/display/cellsnet/Copy+Shapes+between+Worksheets


Thank you.

Thanks for the references… Will get back again if I need any clarifications.

HI,

Now am able to copy the data from one sheet to another using copyCellsRamge() method. I need to now copy the shapes from the source sheet to destination sheet. Is it posible to get the position and size of the shape from the source excel sheet and get the relative postion (where the shape needs to be copied ) in the destination excel sheet and copy the shape ?

Thanks,

Geetha

Hi Geetha,


Please see the below linked article on the subject [copying shapes between worksheets]. Also, feel free to write back. Thank you.

Note: You have marked you first post related to JAVA API but some of the replies are pointing to .NET. So I’m supplying you both links.

https://docs.aspose.com/display/cellsjava/Copy+Shapes+between+Worksheets
https://docs.aspose.com/display/cellsnet/Copy+Shapes+between+Worksheets

Hi can u please provide code for merging multiple excel file (.xlsx) around 30 files into one excel file using java… Aspose.cell

Hi Sachin Dagar,


Well, I think you may try to use Workbook.combine() method to merge workbooks (you have to loop through your files to be opened and then merge the workbooks one by one into your master workbook accordingly) , see the document on combining multiple files into one file for your reference:
https://docs.aspose.com/display/cellsjava/Combine+Multiple+Workbooks+into+a+Single+Workbook

Thank you.