Cell Comments
This guide explains how to create a spreadsheet cell with comments.
Before you begin
You should get your API key from your UniCloud account.
If this is your first time using UniOffice SDK, follow this guide to set up a local development environment.
Clone the project repository
In your terminal, clone the examples repository. It contains the Go code we will be using for this guide.
git clone https://github.com/unidoc/unioffice-examples
To get the example navigate to the path spreadsheet/comments
folder in the unioffice-examples
directory.
cd unioffice-examples/spreadsheet/comments/
How it works
The import
section in lines 4-10
imports the necessary packages.
Then in the init
function a metered license API key is set.
The main
function is defined in line 21-35
. In lines 22-24
, a new workbook with a new sheet is created using:
ss := spreadsheet.New()
sheet := ss.AddSheet()
Line 26
set the sheet cell A1
with a text Hello World!
.
Then lines 27-28
add comments to cell A1
and C10
using:
sheet.Comments().AddCommentWithStyle("A1", "Gopher", "This looks interesting.")
sheet.Comments().AddCommentWithStyle("C10", "Gopher", "This is a different comment.")
Finally, the spreadsheet is validated and saved to file in line 30-34
.
Run the code
Run the following command to create the sample spreadsheet file.
go run main.go
Sample output
Spreadsheet file.