As tag "office-excel-itpro" focuses on general issue of Excel client. If you need the code of C#, I would like to suggest you post a new thread on Q&A forum with tag "dotnet-csharp", and confirm whether this team could help you. Thanks for your understanding.
From the perspective of Office, you could use command below to check license status, such as Licensed, Notification or others.
Search CMD, right-click the Command Prompt and run as administrator. Then copy and paste the command below in it, click Enter at last:
cscript.exe "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" /dstatus
(If you are running 32-bit Office on a 64-bit operating system)
cscript.exe "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" /dstatus
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.