Can I combine sheets from separate workbooks into one workbook?

Not Answered This post has 0 verified answers | 4 Replies | 2 Followers Thread's RSS feed.

tomdnaughton
Points 210
Replied On: Mon, Oct 9 2017 1:41 PM Reply

I need to combine sheets from different Excel sources into a single workbook:  open a saved Excel workbook, grab a worksheet and put it into the spreadsheet control, do some manipulation.  Then open a different Excel workbook, grab another worksheet and add it as a new worksheet in the spreadsheet control's active workbook.  Then save the spreadsheet control's active workbook under a new name.  I can't seem to figure out if this is possible, or if so, how to do it.

I can add a new worksheet to the active workbook, but it's empty. I can't seem to set it to another worksheet loaded from a different Excel file.  I can copy values row by row and column by column, then then I lose all formatting, merges, etc.

Please let me know if I what I'm attempting is possible.

Thanks.

  • Post Points: 20

All Replies

Mike Bowshewicz
Points 11,595
Infragistics Employee
Replied On: Mon, Oct 9 2017 5:23 PM Reply

Hello,

I will look into whether it is possible to accomplish this with our toolset. I think it will be possible to accomplish with minimal code as long as the worksheets stay separate. However, I will need to do some research to determine if this is the case.

I will follow up with my progress, as well as a code snippet or sample application should this be feasible to implement.

Please let me know if you have any questions.

Sincerely,

Mike B
Software Developer

  • Post Points: 5
Mike Bowshewicz
Points 11,595
Infragistics Employee
Replied On: Wed, Oct 11 2017 10:03 AM Reply

Hello,

It is possible to do this by looping through the rows and cells in one workbook and adding them to the second. You can also solve it using Excel Interop.

The sample code is provided on this thread: https://www.infragistics.com/community/forums/t/83297.aspx

The thread combines two worksheets into one, but the code should be easy to adapt to adding a new worksheet instead. Please let me know if you have any questions.

Sincerely,

Mike B
Software Developer

  • Post Points: 20
tomdnaughton
Points 210
Replied On: Wed, Oct 11 2017 10:14 AM Reply

Not quite the solution I was hoping for, but I'll give a shot.

Thanks.

  • Post Points: 20
Mike Bowshewicz
Points 11,595
Infragistics Employee
Replied On: Thu, Oct 12 2017 10:12 AM Reply

Please let me know whether this works for you.

Sincerely,

Mike B
Software Developer

  • Post Points: 5
Page 1 of 1 (5 items) | RSS