How to Retrieve the Logged-In User in Excel Online with JavaScript
Question details
The user needs to retrieve the signed-in user's information and insert the current date into specific worksheet cells using JavaScript in Excel Online.

- Product
- Excel Online
- Device & OS
- not provided
- Scenario
- Developing custom scripts to automate user tracking and date insertion within a cloud-based spreadsheet.
- Observed behavior
- The request requires specialized JavaScript or Office Scripts development expertise that falls outside the scope of general installation and activation support forums.
Before writing your script, determine whether you are using the Office JavaScript API for an Add-in or Office Scripts (TypeScript), and ensure your Microsoft 365 admin has enabled script execution permissions.
Seek Expert Developer Support on Microsoft Q&A
Because custom JavaScript and Office Scripts development is highly specific, posting your exact requirements in specialized developer forums is the best way to get functional code snippets.
General Microsoft 365 support forums typically handle installation and activation issues. For complex automation logic, engaging with the developer community ensures you receive accurate, context-aware API guidance.
Open your web browser and go to the official Microsoft Q&A developer platform.
Create a new post detailing your intended Excel Online environment and specify the exact script type you are attempting to use (e.g., Office Web Add-in API or Office Scripts).
Include the specific worksheet cell addresses where the user details and the current date need to be inserted.
Clearly state the required date format (such as MM/DD/YYYY or DD-MM-YYYY) so community experts can format the JavaScript `Date()` output correctly.

Use the Office JavaScript API (Concept)
If you are actively developing an Office Web Add-in, you can use built-in context properties to retrieve user profile data.
Automate Worksheets Easily Using JavaScript Macros in WPS Office
If you prefer to automate spreadsheets using JavaScript without the complex cloud deployment requirements of Excel Online Add-ins, WPS Office features a native, built-in JavaScript Macro (JSA) editor right on your desktop.
- 1. Open WPS Spreadsheet: Launch WPS Office and open a new or existing spreadsheet document.
- 2. Access the Macro Editor: Navigate to the 'Tools' tab on the top ribbon and click the 'Macro' button.
- 3. Launch WPS Macro Editor: Select 'WPS Macro Editor' from the dropdown menu to open the dedicated JavaScript development environment.
- 4. Write Your JavaScript Automation: Write your JS code using the `Date()` object and assign it to a worksheet cell, for example: `Range("A1").Value2 = new Date();`.
- 5. Run Your Script: Click the run button in the editor to instantly execute your JavaScript automation on your local spreadsheet.

Frequently Asked Questions
Can I use standard web JavaScript to automate Excel Online?
Not directly. Automating Excel Online requires either Office Scripts (which uses TypeScript) or the specialized Office JavaScript API for Web Add-ins. Standard DOM-based web JavaScript will not interact with the spreadsheet grid.
How do I insert the current date in an online spreadsheet without code?
You can use the built-in spreadsheet functions `=TODAY()` for the current date or `=NOW()` for the current date and time. Alternatively, you can use the keyboard shortcut 'Ctrl + ;' to insert a static current date.
Does WPS Office support JavaScript for spreadsheet automation?
Yes, WPS Office has native support for JavaScript Macros (JSA). This allows developers to write automation scripts using standard JavaScript syntax directly within the desktop application, serving as a modern alternative to traditional VBA.
Where is the best place to ask advanced Microsoft Office API questions?
For highly technical API queries, Office Scripts, and Add-in development, the official Microsoft Q&A developer forums or Stack Overflow are the best platforms to get specialized, code-level support.




