Parse References

This guide will explain the process of parsing range references with sheet names using UniOffice library.

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/references-with-sheet-name folder in the unioffice-examples directory.

cd unioffice-examples/spreadsheet/references-with-sheet-name/

How it works

First the necessary libraries are imported in lines 6-12.
The metered license key is set inside the init function in lines 14-21.

The main function defined in lines 23-29 parses some range references by calling the parse function. The parse function defined in lines 31-38 parses the range reference passed to it. First the CellReference is obtained in line 32 using reference.ParseRangeReference(s). Then the parsed information is printed in lines 36 and 39 using:

fmt.Println(from.RowIdx, from.Column, from.SheetName)
fmt.Println(to.RowIdx, to.Column, to.SheetName)

Run the code

Use the following command to run the code.

go run main.go

Sample Output

1 A 
3 A 
1 A Sheet1
3 A Sheet1
1 A Sheet1!
3 A Sheet1!
1 A Shee!t1
3 A Shee!t1
1 A !Sheet1
3 A !Sheet1

Got any Questions?

We're here to help you.