Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: NPM Build
run: |
npm install
npm ci
node ./node_modules/.bin/rollup -c
cp LICENSE ./dist
cp README.md ./dist
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
GOOS: js
GOARCH: wasm
GO111MODULE: on
permissions:
contents: read
id-token: write
steps:

- name: Install Go
Expand Down Expand Up @@ -58,19 +61,20 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20.18.1
node-version: 20.19.6
registry-url: 'https://registry.npmjs.org'

- name: NPM Build
run: |
npm install
npm install -g npm@latest
npm ci
node ./node_modules/.bin/rollup -c
cp LICENSE ./dist
cp README.md ./dist
cp package.json ./dist
cp src/index.d.ts ./dist
npm publish

- name: NPM Publish
uses: JS-DevTools/npm-publish@v4
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./dist/package.json
run: |
npm publish
10 changes: 5 additions & 5 deletions cmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.24.0

require (
github.com/stretchr/testify v1.11.1
github.com/xuri/excelize/v2 v2.10.1-0.20251128004124-f1ac51e63bc8
golang.org/x/image v0.33.0
github.com/xuri/excelize/v2 v2.10.1-0.20251212004743-418be6db1900
golang.org/x/image v0.34.0
)

require (
Expand All @@ -16,8 +16,8 @@ require (
github.com/tiendc/go-deepcopy v1.7.2 // indirect
github.com/xuri/efp v0.0.1 // indirect
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/crypto v0.46.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/text v0.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
20 changes: 10 additions & 10 deletions cmd/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ github.com/tiendc/go-deepcopy v1.7.2 h1:Ut2yYR7W9tWjTQitganoIue4UGxZwCcJy3orjrrI
github.com/tiendc/go-deepcopy v1.7.2/go.mod h1:4bKjNC2r7boYOkD2IOuZpYjmlDdzjbpTRyCx+goBCJQ=
github.com/xuri/efp v0.0.1 h1:fws5Rv3myXyYni8uwj2qKjVaRP30PdjeYe2Y6FDsCL8=
github.com/xuri/efp v0.0.1/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/excelize/v2 v2.10.1-0.20251128004124-f1ac51e63bc8 h1:BMTZwsTDkAGubaojDitcn7jw+VbPCRT5vpV2C4eD/gY=
github.com/xuri/excelize/v2 v2.10.1-0.20251128004124-f1ac51e63bc8/go.mod h1:B1Yl9Szv1D018lVoZttJ5lJkw8AP40Ysb0uKP4VO2hA=
github.com/xuri/excelize/v2 v2.10.1-0.20251212004743-418be6db1900 h1:vtctSAFjYukuBb04Gb/1mTkJ5byBvlONEtiyNA1r/Gk=
github.com/xuri/excelize/v2 v2.10.1-0.20251212004743-418be6db1900/go.mod h1:B1Yl9Szv1D018lVoZttJ5lJkw8AP40Ysb0uKP4VO2hA=
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 h1:+C0TIdyyYmzadGaL/HBLbf3WdLgC29pgyhTjAT/0nuE=
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ=
golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8=
golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU=
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
28 changes: 28 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func regInteropFunc(f *excelize.File, fn map[string]interface{}) interface{} {
"GetComments": GetComments(f),
"GetConditionalStyle": GetConditionalStyle(f),
"GetCustomProps": GetCustomProps(f),
"GetDataValidations": GetDataValidations(f),
"GetDefaultFont": GetDefaultFont(f),
"GetDefinedName": GetDefinedName(f),
"GetDocProps": GetDocProps(f),
Expand Down Expand Up @@ -2181,6 +2182,33 @@ func GetCustomProps(f *excelize.File) func(this js.Value, args []js.Value) inter
}
}

// GetDataValidations returns data validations list by given worksheet name.
func GetDataValidations(f *excelize.File) func(this js.Value, args []js.Value) interface{} {
return func(this js.Value, args []js.Value) interface{} {
ret := map[string]interface{}{"dataValidations": []interface{}{}, "error": nil}
if err := prepareArgs(args, []argsRule{
{types: []js.Type{js.TypeString}},
}); err != nil {
ret["error"] = err.Error()
return js.ValueOf(ret)
}
dataValidations, err := f.GetDataValidations(args[0].String())
if err != nil {
ret["error"] = err.Error()
return js.ValueOf(ret)
}
for _, dv := range dataValidations {
if jsVal, err := goValueToJS(reflect.ValueOf(*dv),
reflect.TypeOf(excelize.DataValidation{})); err == nil {
x := ret["dataValidations"].([]interface{})
x = append(x, jsVal)
ret["dataValidations"] = x
}
}
return js.ValueOf(ret)
}
}

// GetDefaultFont provides the default font name currently set in the
// workbook. The spreadsheet generated by excelize default font is Calibri.
func GetDefaultFont(f *excelize.File) func(this js.Value, args []js.Value) interface{} {
Expand Down
15 changes: 14 additions & 1 deletion cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func TestComments(t *testing.T) {
assert.Equal(t, "sheet SheetN does not exist", ret.Get("error").String())
}

func TestAddDataValidation(t *testing.T) {
func TestDataValidation(t *testing.T) {
f := NewFile(js.Value{}, []js.Value{})
assert.True(t, f.(js.Value).Get("error").IsNull())
dv := js.ValueOf(map[string]interface{}{})
Expand All @@ -442,6 +442,19 @@ func TestAddDataValidation(t *testing.T) {

ret = f.(js.Value).Call("AddDataValidation", js.ValueOf("SheetN"), dv)
assert.Equal(t, "sheet SheetN does not exist", ret.Get("error").String())

ret = f.(js.Value).Call("GetDataValidations", js.ValueOf("Sheet1"))
assert.True(t, ret.Get("error").IsNull())
assert.Equal(t, ret.Get("dataValidations").Length(), 1)

ret = f.(js.Value).Call("GetDataValidations")
assert.EqualError(t, errArgNum, ret.Get("error").String())

ret = f.(js.Value).Call("GetDataValidations", js.ValueOf(nil))
assert.Equal(t, errArgType.Error(), ret.Get("error").String())

ret = f.(js.Value).Call("GetDataValidations", js.ValueOf("SheetN"))
assert.Equal(t, "sheet SheetN does not exist", ret.Get("error").String())
}

func TestFormControl(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "excelize-wasm",
"version": "0.1.0",
"version": "0.1.1",
"description": "A pure WebAssembly / Javascript port of Go Excelize library that allow you to write to and read from XLAM / XLSM / XLSX / XLTM / XLTX files",
"author": "xuri <xuri.me@gmail.com>",
"homepage": "https://xuri.me/excelize",
Expand Down
6 changes: 6 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2430,6 +2430,12 @@ declare module 'excelize-wasm' {
*/
GetCustomProps(): { props: CustomProperty[], error: string | null }

/**
* GetDataValidations returns data validations list by given worksheet name.
* @param sheet The worksheet name
*/
GetDataValidations(sheet: string): { dataValidation: DataValidation[], error: string | null }

/**
* GetDefaultFont provides the default font name currently set in the
* workbook. The spreadsheet generated by excelize default font is Calibri.
Expand Down