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

Free Support Forum - aspose.com

Create Excel from binary stream XLS file

Hi, Does Aspose.Cells java library have libraries to create a new spreadsheet for each of the binary XLS stream file? I have a external java program that returns XLS workbook. There will be multiple XLS stream that I will collect. I like to take each workbook stream (contains single sheet) and merge into single XLS output this results in add\create new sheet to the target XLS.

Example, 3 XLS file stream request from my existing program to consolidate create sinlge XLS and the file contains 3 sheets.

Do you have example demonstrating this capabilities? Thanks!!

Hi Jeremy,

Thanks for your posting and using Aspose.Cells.

First, you will create a Workbook object from your binary stream XLS file. Once, you have obtained the workbook, then you will use Workbook.combine() method to combine/merge two workbooks into a single workbook. You will repeat the same thing for all of your binary stream XLS files and you will then get a consolidated workbook which contains all the individual worksheets inside it.

Please see the following documentation article for your further reference.


Thanks for the excellent reference. Can you tell me the difference btw combine vs. copy worksheet. I found the method to copy worksheet earlier and wonder if they are the same ? If not which one performs faster? I could have upto 50 sheets.

Additionally, if I need to insert a sheet (copy) in the middle how would you do that? Will you have to move the sheet? Example, I have existing workbook with 5 spreadsheet, I like to insert starting on the 3rd sheet. Current, I think of doing add/copy/move it. I was wondering if I do a add to then workbook can I set the new spreadsheet position without overwrite, in essence it does a shift during add? Or moving sheet is required? Can you give me short cut on moving sheet?

Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

Combine method combines the workbook. If workbook1 contains 3 worksheets and workbook2 contains 4 worksheet, it will combine all of them into single workbook which will contain 7 worksheets.

Copy worksheet method just copies single worksheet into your destination workbook. Both methods are good performance wise when there is a single worksheet. But when there are multiple worksheets, then combine method will give you better performance.

Once, you have inserted your worksheet, you can move it to your desired position using MoveTo() method. Please see the following code for your reference.

Java


workbook.getWorksheets().get(“MySheet1”).moveTo(2);