gdemin / excel.link

Convenient Data Exchange between R and Microsoft Excel
56 stars 16 forks source link

Duplicating worksheet #14

Closed qtaa246 closed 6 years ago

qtaa246 commented 6 years ago

Hi

Is there any way to duplicate worksheet like [holding Crtl key + dragging worksheet tap] ?

gdemin commented 6 years ago

You can use the following function:

xl.sheet.duplicate = function(before = NULL){
    ex = xl.get.excel()
    if (is.null(before)) {
        before = ex[['ActiveWorkbook']][['ActiveSheet']]
    } else {
        before = ex[['ActiveWorkbook']][['Sheets']][[before]]
    }
    ex[['ActiveWorkbook']][['Activesheet']]$copy(before = before)
    invisible(ex[['ActiveWorkbook']][['Activesheet']][['Name']])
}
qtaa246 commented 6 years ago

Thank you !

gdemin commented 6 years ago

Fixed in version 0.9.8