forked from qax-os/excelize
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add datavalidation test and fixed struct bug issue qax-os#240
- Loading branch information
1 parent
0548852
commit 24a8d64
Showing
3 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters