Univer Go Launches AI-Powered API Writing Assistance

Univer Go Launches AI-Powered API Writing Assistance

Background

When expanding Univer applications using the Univer API, many developers find it challenging, especially those who are not familiar with the API. Traditionally, we have to frequently consult official documentation to understand how to use the API correctly. To simplify the development process and improve efficiency, Univer Go has launched a feature that provides AI-powered API writing assistance, helping developers quickly generate high-quality code. By simply downloading the latest version of the Univer Go client, you can start using this feature for free.

This feature leverages advanced AI technology to automatically generate related API code based on user needs. Whether it's simple operations or complex API usage, the AI assistant can provide code suggestions, reducing the need for manual code writing and making the development process smoother.

\> Univer is an isomorphic full-stack framework for creating and editing spreadsheets, docs, and slides across client and server.

\> Follow Univer Github https://github.com/dream-num/univer

\>Official Website https://go.univer.ai/en-US?

\>Video Tutorial https://youtu.be/jHdX-08Kdvk?si=trUy3XMJ1eFQI1LR

Steps to Use the Feature

AI-Assisted Code Writing

Next, let's take a detailed look at how to use the AI-powered code writing assistance.

Step 1: Create a Workspace and Script

First, open the Univer Go client, create a new Workspace, and create a new Script within the Workspace.

Step 2: Open the AI Dialog Box

In the editor, you can use a shortcut to bring up the AI dialog box. For Windows users, press Ctrl + K, and for macOS users, press Command + K. This will open a dialog box where you can enter your question or request.

Step 3: Enter Your Request

In the dialog box, type the description of the code you want to generate. For example, you can type: "Set values for A1:B2." Then, click the "Generate" button, and wait a moment for the AI to generate the corresponding code. Below is an example of the code generated by AI:

function setInitialValues() {

const workbook = univerAPI.getActiveWorkbook();

const sheet = workbook.getActiveSheet();

const range = sheet.getRange('A1:B2');

// Set values for 2x2 range

range.setValues([

[1, 2],

[3, 4]

]);

}

Step 4: Apply the Generated Code

If you’re satisfied with the generated code, click the “Accept” button to apply it to your Script. You can place the generated function inside the onOpen function so it will run automatically when the sheet is opened.

Step 5: Preview the Results

Finally, preview the sheet, and you’ll see that the values for A1:B2 have been successfully set. This demonstrates that the AI-generated Univer API code is standard and works as expected.

Logging Feature

In addition to the AI-powered code writing assistance, Univer Go has also introduced a highly useful feature: logging. With this feature, developers can easily log the execution process and results of their code, making it easier to debug and analyze.

Step 1: Generate Code for Logging

Building on the previous code, we can now generate code for logging. Once again, open the AI dialog box and type: “output the text in A1:B2 to the log” Click “Generate” and wait for the code to be created. The AI will generate the following code:

// Get values from range A1:B2

const values = range.getValues();

// Log the values

Logger.log('Values in A1:B2:', values);

Step 2: Review and Apply the Generated Code

Review the generated code and confirm its correctness. Once satisfied, click the “Accept” button to add the code to your Script. You can place the logging code in an appropriate location to record the required values during execution.

Step 3: View the Execution Logs

Now, open the execution log panel and click onOpen to execute the code. You will be able to see the logged output in the execution log panel, confirming that the values from A1:B2 have been successfully logged.

Conclusion

With the new AI-powered code writing assistance and logging features, Univer Go provides a more efficient workflow for developers. The AI can generate standard API code based on user input, significantly reducing the learning curve and development time. Meanwhile, the logging feature offers developers a powerful tool for debugging and analysis, helping them quickly identify issues.

With these two new features, Univer Go continues to enhance the user experience, helping more users efficiently work with the Univer API and quickly bring their ideas to life. If you haven’t experienced these new features yet, download the latest version of the Univer Go client and start experiencing the power of the AI programming assistant today!

https://univer.hashnode.dev/get-rid-of-excel-and-deploy-a-private-spreadsheet-system