-
Notifications
You must be signed in to change notification settings - Fork 0
/
sheet.go
38 lines (33 loc) · 1006 Bytes
/
sheet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package models
import (
"fmt"
// Third-party libraries
"github.com/Deathfireofdoom/excel-client-go/pkg/utils"
)
// Sheet represents a single worksheet within a spreadsheet.
// It contains a collection of cells, a name, and a position.
type Sheet struct {
ID string `json:"id"`
WorkbookID string `json:"workbook_id"`
Pos int `json:"pos"` // Position of the sheet within the spreadsheet
Name string `json:"name"` // Name of the sheet
Cells []Cell `json:"cells"` // Collection of cells within the sheet
}
// NewSheet creates a new Sheet instance.
// If id is empty, a new UUID will be generated.
func NewSheet(workbookdId string, pos int, name, id string) (*Sheet, error) {
if id == "" {
var err error
id, err = utils.GenerateUUID()
if err != nil {
return nil, fmt.Errorf("failed to generate UUID for Sheet: %w", err)
}
}
return &Sheet{
ID: id,
WorkbookID: workbookdId,
Pos: pos,
Name: name,
Cells: nil,
}, nil
}