Skip to content

How to Use Aspose.Cells Spreadsheet Merge Sample

Assad Mahmood Qazi edited this page Feb 27, 2014 · 1 revision

Functionality

Aspose.Cells Document Merge Sample allows you to merge multiple workbooks into a single workbook using Aspose.Cells for Cloud API in your Salesforce Portal. You need to provide two spreadsheet workbooks. Aspose.Cells Workbook Merge will merge the excel files and provides output as one single merged file.

Process

Before using Aspose.Cells Workbook Merge Sample you need to install Aspose Cloud Samples Package for Salesforce. Please read the installation process here.

  • After successful installation please open "Aspose Samples" App.
  • Open "Aspose Cloud Merge Workbook" tab.
  • Fill the on screen from and execute the Sample.

APEX Code Snippet

public String ExecuteMerge(String firstWb, String secondWb) {
    
        try{    
            //build URI
            String strURI = Product.BaseProductUri + '/cells/' + firstWb + '/merge?mergeWith=' + secondWb;
            String signedURI = Utils.Sign(strURI);
            
            String strJSON = Utils.ProcessCommand(signedURI, 'POST', '' , 'json');
            this.apiResponse = strJSON;
            
            //prepare signed download link
            String downloadURL = null;
            Map<String, Object> params = (Map<String, Object>) JSON.deserializeUntyped(strJSON);
            if(params.containsKey('Workbook')){
                strURI = Product.BaseProductUri + '/cells/' + firstWb;
                downloadURL = Utils.Sign(strURI);
            }
            
            return downloadURL;
            
            
        } catch (Exception ex) {
            system.debug(ex);
            return null;
        }
    
    }

ProcessCommand method is available in Utils Class. Please check the source.