Spaces not allowed in TableName


In the file ExcelTableCollection.cs it says that spaces in table names are not allowed:
private void ValidateTableName(string Name)
    if (string.IsNullOrEmpty(Name))
        throw new ArgumentException("Tablename is null or empty");

    char firstLetterOfName = Name[0];
    if (Char.IsLetter(firstLetterOfName) == false && firstLetterOfName != '_' && firstLetterOfName != '\\')
        throw new ArgumentException("Tablename start with invalid character");

    if (Name.Contains(" "))
        throw new ArgumentException("Tablename has spaces");

In the previous version this wasn't a problem, but now it became an Exception, Is there a specific reason for this?


ByFe wrote Feb 15 at 1:25 PM

Excel simply does not allow ListObjects with whitespaces in the name.
You can check that by yourself by trying to add some whitespace to a table name.
You will be greeted by a nice little error message that tells you its not allowed (this behavior exists since ListObjects were implemented in Excel as far as I remember).

DarkLite1 wrote Feb 17 at 1:24 PM

Thanks for the feedback, that wasn't clear to me. Good to know, we can close this ticket then.