Back to Devexpress

Worksheet.CodeName Property

officefileapi-devexpress-dot-spreadsheet-dot-worksheet-acebfaa2.md

latest2.1 KB
Original Source

Worksheet.CodeName Property

Gets or sets the worksheet’s code name.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
string CodeName { get; set; }
vb
Property CodeName As String

Property Value

TypeDescription
String

The code name.

|

Remarks

Use the CodeName property to specify an internal worksheet name that does not change when a user renames the worksheet.

The following method returns a worksheet with the specified code name:

csharp
using DevExpress.Spreadsheet;
using System.Linq;
// ...

private Worksheet GetSheetByCodeName(IWorkbook workbook, string codeName) {
    return workbook.Worksheets.SingleOrDefault(x => x.CodeName == codeName);
}
vb
Imports DevExpress.Spreadsheet
Imports System.Linq
' ...

Private Function GetSheetByCodeName(ByVal workbook As IWorkbook, ByVal codeName As String) As Worksheet
    Return workbook.Worksheets.SingleOrDefault(Function(x) x.CodeName = codeName)
End Function

You can also use the WorksheetCollection.Item property to access a worksheet by its index or name. See the following help topic for details: How to: Access a Worksheet.

See Also

Worksheet Interface

Worksheet Members

DevExpress.Spreadsheet Namespace