let yo= () => {



<button onClick={yo}>new</button>



Read Excel file

using  Microsoft.Office.Interop.Excel;
  #region Read Excel
            //Create COM Objects.
            Application excelApp = new Application();

            if (excelApp == null)
                Console.WriteLine("Excel is not installed!!");

            Workbook excelBook = excelApp.Workbooks.Open(@"C:\Users\anjanic\Documents\Anjani\RS Bonus Script Template.xlsx");

            _Worksheet excelSheet = excelBook.Sheets[1];
            Range excelRange = excelSheet.UsedRange;

            int rows = excelRange.Rows.Count;
            int cols = excelRange.Columns.Count;

            for (int i = 1; i <= rows; i++)
                //create new line
                for (int j = 1; j <= cols; j++)

                    //write the console
                    if (excelRange.Cells[i, j] != null && excelRange.Cells[i, j].Value2 != null)
                        Console.Write(excelRange.Cells[i, j].Value2.ToString() + "\t");
            //after reading, relaase the excel project

Hub Sites

In windows search for “Microsoft Online Management Shell” -> Right click and “Run as Administrator”

First connect to SharePoint Online


To get all the Hub sites:


To Unregister a hub site:

Unregister-SPOHubSite -Identity https://*****.sharepoint.com/sites/******

or you can provide the GUID of the site

Unregister-SPOHubSite -Identity <guid&gt;

After all the task are done, close the connection


Code to delete subsites

Add “Microsoft.SharePoint.Client.dll” to your solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;

namespace DeleteSubSite
    class Program
        static void Main(string[] args)

            string webSPOUrl = "https://*******.sharepoint.com/news/";
            string userName = "*******@**********.com";
            SecureString password = FetchPasswordFromConsole();
            GetAllSubSites(webSPOUrl, userName, password);
        #region fetch password
        private static SecureString FetchPasswordFromConsole()

            //Enter your password
            string password = "**********";

            var securePassword = new SecureString();
            //Convert string to secure string  
            foreach (char c in password)
            return securePassword;
        #region GetAllSubSites
        private static void GetAllSubSites(string path, string userName, SecureString password)
            // ClienContext - Get the context for the SharePoint Online Site               
            using (var clientContext = new ClientContext(path))
                // SharePoint Online Credentials    
                clientContext.Credentials = new SharePointOnlineCredentials(userName, password);

                // Get the SharePoint web  
                Web web = clientContext.Web;
                clientContext.Load(web, website => website.Webs, website => website.Title);

                // Execute the query to the server  

                // Loop through all the webs  
                foreach (Web subWeb in web.Webs)

                    if (subWeb.Url.Contains(path))
                        string newpath = subWeb.Url;
                        GetAllSubSites(newpath, userName, password);
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("Deleting site: " + subWeb.Title + "-------" + subWeb.Url);
                        DeleteSubSite(subWeb.Url, userName, password);

        public static void DeleteSubSite(string webSPOUrl, string userName, SecureString password)

            using (var clientContext = new ClientContext(webSPOUrl))
                clientContext.Credentials = new SharePointOnlineCredentials(userName, password);

                Web web = clientContext.Web;


                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Site deleted");




SPFx app as Teams Tab

This blog describes how to create and add SPFx app as Teams Tab. Also, this blog is with respect to SharePoint framework version 1.7

Create your SPFx web part, After you are done with development, deploy it

Add the package to your App catalog

Now in your web part, go to Teams folder.

In Teams folder, there will be 3 files (manifest.json, tab20*20.png and tab96*96.png)

Zip the 3 files in Teams folder, make sure your zip file doesn’t contain any folders in it.

Now go to respective team of site in teams, go to General -> Click on + ->Manage Apps -> Upload a custom app -> and upload the zip file which you created earlier

That’s it

Your app will be added as teams tab

dll installation error

Once I downloaded an SPFx web part from GitHub and tried to run in my machine.

I ran npm install then gulp serve

Everything was working fine, but when I see my solution in Visual Studio Code, it showed errors on screen (cannot fine ‘react’, ‘@pnp/sp’,………..) as below

To fix those errors I did some research and was able get rid of them by running below:

npm install --save react react-dom @types/react @types/react-dom
npm i lts office-ui-fabric-react
npm install lts @pnp/logging @pnp/common @pnp/odata @pnp/sp --save

String replace

To replace a string:

let str:string=”Hello world welcome”;

str.replace(" ","!");

Output: Hello!world weclome

To replace all the occurrences of a string

str.replace(new RegExp(' ', 'g'),"!");

Output: Hello!world!welcome