public void CopySheetCommand(Excel.Workbook workbook, string name, string newName, ReferenceEnum referenceType = ReferenceEnum.ByName) { bool isAnInteger = int.TryParse(name, out int indexValue); if (referenceType == ReferenceEnum.ByIndex && isAnInteger == true) { workbook.CopySheet(indexValue, newName); } else { workbook.CopySheet(name, newName); } }