I had this question been asked in the forums a couple of times. There are two ways to achieve this.
Option 1
If you have Admin access to your Office 365 tenant, you can simply do this via the Admin portal.
Go to Admin -> Active Users
Simply click on Export Users to export the list in excel.
Option 2:
If you are not an admin, you can achieve this via Power Automate. Steps below:
Just make sure that you leave the Search term field in Search for Users action as Blank and set the Is search term required to No.
Thanks for another great post.
Thanks!