From 24a8d64f939afb5c15b04e552b3d3b7046daa851 Mon Sep 17 00:00:00 2001 From: rentiansheng Date: Sat, 1 Sep 2018 19:38:30 +0800 Subject: add datavalidation test and fixed struct bug issue #240 --- datavalidation_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 datavalidation_test.go (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go new file mode 100644 index 0000000..718131f --- /dev/null +++ b/datavalidation_test.go @@ -0,0 +1,32 @@ +package excelize + +import ( + "testing" +) + +func TestDataValidation(t *testing.T) { + xlsx := NewFile() + + dvRange := NewDataValidation(true) + dvRange.Sqref = "A1:B2" + dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorBetween) + dvRange.SetError(DataValidationErrorStyleStop, "error title", "error body") + xlsx.AddDataValidation("Sheet1", dvRange) + + dvRange = NewDataValidation(true) + dvRange.Sqref = "A3:B4" + dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorGreaterThan) + dvRange.SetInput("input title", "input body") + xlsx.AddDataValidation("Sheet1", dvRange) + + dvRange = NewDataValidation(true) + dvRange.Sqref = "A5:B6" + dvRange.SetDropList([]string{"1", "2", "3"}) + xlsx.AddDataValidation("Sheet1", dvRange) + + // Test write file to given path. + err := xlsx.SaveAs("./test/Bookdatavalition.xlsx") + if err != nil { + t.Error(err) + } +} -- cgit v1.2.1 From 2da107d3b20a5561d311466b7b2cb91170885f9f Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 2 Sep 2018 01:44:32 +0800 Subject: Fix typo. --- datavalidation_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index 718131f..32f9059 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -25,7 +25,7 @@ func TestDataValidation(t *testing.T) { xlsx.AddDataValidation("Sheet1", dvRange) // Test write file to given path. - err := xlsx.SaveAs("./test/Bookdatavalition.xlsx") + err := xlsx.SaveAs("./test/Book_data_validation.xlsx") if err != nil { t.Error(err) } -- cgit v1.2.1 From 93cbafb0e2ff5df0236d543650712cd175cd789d Mon Sep 17 00:00:00 2001 From: rentiansheng Date: Tue, 4 Sep 2018 13:40:53 +0800 Subject: data validation drop-down list use sqref cell issue #268 --- datavalidation_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index 32f9059..f3db81c 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -24,6 +24,14 @@ func TestDataValidation(t *testing.T) { dvRange.SetDropList([]string{"1", "2", "3"}) xlsx.AddDataValidation("Sheet1", dvRange) + xlsx.SetCellStr("Sheet1", "E1", "E1") + xlsx.SetCellStr("Sheet1", "E2", "E2") + xlsx.SetCellStr("Sheet1", "E3", "E3") + dvRange = NewDataValidation(true) + dvRange.Sqref = "A7:B8" + dvRange.SetSqrefDropList("$E$1:$E$3", true) + xlsx.AddDataValidation("Sheet1", dvRange) + // Test write file to given path. err := xlsx.SaveAs("./test/Book_data_validation.xlsx") if err != nil { -- cgit v1.2.1 From b4a6e61ec34d4a0db1110907cc969f0d7d38991a Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 12 Sep 2018 15:47:56 +0800 Subject: Fix golint errors under confidence 0.1 --- datavalidation_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index f3db81c..8134b72 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -1,3 +1,11 @@ +// Package excelize providing a set of functions that allow you to write to +// and read from XLSX files. Support reads and writes XLSX file generated by +// Microsoft Excel™ 2007 and later. Support save file without losing original +// charts of XLSX. This library needs Go version 1.8 or later. +// +// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of +// this source code is governed by a BSD-style license that can be found in +// the LICENSE file. package excelize import ( -- cgit v1.2.1 From 4f47737d64fc9d9108675cbc1e73ae93c2d723a9 Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 13 Sep 2018 10:38:01 +0800 Subject: Complete unit testing case for data validation --- datavalidation_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index 8134b72..9899334 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -19,6 +19,8 @@ func TestDataValidation(t *testing.T) { dvRange.Sqref = "A1:B2" dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorBetween) dvRange.SetError(DataValidationErrorStyleStop, "error title", "error body") + dvRange.SetError(DataValidationErrorStyleWarning, "error title", "error body") + dvRange.SetError(DataValidationErrorStyleInformation, "error title", "error body") xlsx.AddDataValidation("Sheet1", dvRange) dvRange = NewDataValidation(true) @@ -36,12 +38,20 @@ func TestDataValidation(t *testing.T) { xlsx.SetCellStr("Sheet1", "E2", "E2") xlsx.SetCellStr("Sheet1", "E3", "E3") dvRange = NewDataValidation(true) - dvRange.Sqref = "A7:B8" + dvRange.SetSqref("A7:B8") + dvRange.SetSqref("A7:B8") dvRange.SetSqrefDropList("$E$1:$E$3", true) + err := dvRange.SetSqrefDropList("$E$1:$E$3", false) + t.Log(err) xlsx.AddDataValidation("Sheet1", dvRange) + dvRange = NewDataValidation(true) + dvRange.SetDropList(make([]string, 258)) + err = dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorGreaterThan) + t.Log(err) + // Test write file to given path. - err := xlsx.SaveAs("./test/Book_data_validation.xlsx") + err = xlsx.SaveAs("./test/Book_data_validation.xlsx") if err != nil { t.Error(err) } -- cgit v1.2.1 From 6ced438f39030e8a9a521548d4112dd002dc2ebe Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 14 Sep 2018 00:24:49 +0800 Subject: New function `AddPictureFromBytes()` has been added, this resolve #259 and close #271. --- datavalidation_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index 9899334..0f50f29 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -8,9 +8,7 @@ // the LICENSE file. package excelize -import ( - "testing" -) +import "testing" func TestDataValidation(t *testing.T) { xlsx := NewFile() -- cgit v1.2.1 From 2f146c923ccd19c5ecc1f732b5b09d591fb935a3 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 14 Sep 2018 00:35:47 +0800 Subject: Comments style changed. --- datavalidation_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index 0f50f29..7d10024 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -1,11 +1,13 @@ -// Package excelize providing a set of functions that allow you to write to -// and read from XLSX files. Support reads and writes XLSX file generated by -// Microsoft Excel™ 2007 and later. Support save file without losing original -// charts of XLSX. This library needs Go version 1.8 or later. -// -// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of -// this source code is governed by a BSD-style license that can be found in -// the LICENSE file. +/* +Package excelize providing a set of functions that allow you to write to +and read from XLSX files. Support reads and writes XLSX file generated by +Microsoft Excel™ 2007 and later. Support save file without losing original +charts of XLSX. This library needs Go version 1.8 or later. + +Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of +this source code is governed by a BSD-style license that can be found in +the LICENSE file. +*/ package excelize import "testing" -- cgit v1.2.1 From 13a9769cc5bde486c52d8e45661ff8108cd786ae Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 14 Sep 2018 00:44:23 +0800 Subject: Comments style changed. --- datavalidation_test.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index 7d10024..b9c51ad 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -1,13 +1,11 @@ -/* -Package excelize providing a set of functions that allow you to write to -and read from XLSX files. Support reads and writes XLSX file generated by -Microsoft Excel™ 2007 and later. Support save file without losing original -charts of XLSX. This library needs Go version 1.8 or later. - -Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of -this source code is governed by a BSD-style license that can be found in -the LICENSE file. -*/ +// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of +// this source code is governed by a BSD-style license that can be found in +// the LICENSE file. +// +// Package excelize providing a set of functions that allow you to write to +// and read from XLSX files. Support reads and writes XLSX file generated by +// Microsoft Excel™ 2007 and later. Support save file without losing original +// charts of XLSX. This library needs Go version 1.8 or later. package excelize import "testing" -- cgit v1.2.1 From 3e004d900b103379c2d62657a3070de4a2e8585a Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 14 Sep 2018 00:58:48 +0800 Subject: Comments style changed. --- datavalidation_test.go | 1 + 1 file changed, 1 insertion(+) (limited to 'datavalidation_test.go') diff --git a/datavalidation_test.go b/datavalidation_test.go index b9c51ad..39dd229 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -6,6 +6,7 @@ // and read from XLSX files. Support reads and writes XLSX file generated by // Microsoft Excel™ 2007 and later. Support save file without losing original // charts of XLSX. This library needs Go version 1.8 or later. + package excelize import "testing" -- cgit v1.2.1