![]() The disadvantage: This method is very troublesome if you have to deal with several worksheets or cell ranges. The obvious method: Select the source cell range, copy and paste them into your main workbook. ![]() Otherwise the data source will disconnect and any changes in one sheet won't effect the other. Copy and paste the source content into your main workbook. Otherwise, save will failįor (int wbIndex = 2 wbIndex <= wbIndex++)ĭestinationWb.SaveAs(destinationFilePath) Įdit: notice that you might want to Move method instead of Copy in case you have dependencies between the sheets, e.g. Close source documents before saving destination. Worksheet after = destinationWb.Worksheets įor (int wbIndex = wbIndex >= 2 wbIndex-)įor (int wsIndex = wb.Worksheets.Count wsIndex >= 1 wsIndex-) ![]() Workbook destinationWb = () įoreach (var sourceFilePath in sourceFilePaths) Create a new workbook (index=1) and open source workbooks (index=2,3.) This method takes any number of excel file paths and copy them into a new file: private static void MergeWorkbooks(string destinationFilePath, params string sourceFilePaths)Īpp.DisplayAlerts = false // No prompt when overriding An easier solution is to copy the worksheets themselves, and not their cells.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |