Prevent SharePoint PowerUsers from uploading Excel doucment

In my project there is an requirement that users are not allowed to upload Excel document in to the SharePoint Library. There are various approaches to it. I'm going to pick server side object model here.
 
Add the below piece of code into Item Adding Event receiver to the document library. Your job is done :)
 
       if    (properties.AfterUrl.EndsWith("xlsx"))
            {
                properties.ErrorMessage = "You are not allowed to upload Excel Files!";
                properties.Status = SPEventReceiverStatus.CancelWithError;
                properties.Cancel = true;
            }
 
Happy Share Pointing!!!
Ebook Download
View all
Learn
View all