forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datavalidationlist.go
35 lines (29 loc) · 1.22 KB
/
datavalidationlist.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
// Copyright 2017 FoxyUtils ehf. All rights reserved.
//
// Use of this software package and source code is governed by the terms of the
// UniDoc End User License Agreement (EULA) that is available at:
// https://unidoc.io/eula/
// A trial license code for evaluation can be obtained at https://unidoc.io.
package spreadsheet
import (
"strings"
"github.com/unidoc/unioffice"
"github.com/unidoc/unioffice/schema/soo/sml"
)
// DataValidationList is just a view on a DataValidation configured as a list.
// It presents a drop-down combo box for spreadsheet users to select values. The
// contents of the dropdown can either pull from a rang eof cells (SetRange) or
// specified directly (SetValues).
type DataValidationList struct {
x *sml.CT_DataValidation
}
// SetRange sets the range that contains the possible values. This is incompatible with SetValues.
func (d DataValidationList) SetRange(cellRange string) {
d.x.Formula1 = unioffice.String(cellRange)
d.x.Formula2 = unioffice.String("0")
}
// SetValues sets the possible values. This is incompatible with SetRange.
func (d DataValidationList) SetValues(values []string) {
d.x.Formula1 = unioffice.String("\"" + strings.Join(values, ",") + "\"")
d.x.Formula2 = unioffice.String("0")
}