diff options
author | Ri Xu <xuri.me@gmail.com> | 2017-03-06 12:05:41 +0800 |
---|---|---|
committer | Ri Xu <xuri.me@gmail.com> | 2017-03-06 12:05:41 +0800 |
commit | 1f73f08185e664d6914c8eb849a9797b26067628 (patch) | |
tree | 71ebce585a03f13e5b68c96a12d0aa06a7756a2c /excelize_test.go | |
parent | 48722e6482d97e742755002061bf1c7b042bfb44 (diff) |
- New feature: border setting support (Related issue #21);
- Function parameter code is simplified;
- Fix element `Tint` value parsing error in worksheet;
- Update go test
Diffstat (limited to 'excelize_test.go')
-rw-r--r-- | excelize_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/excelize_test.go b/excelize_test.go index 563f0b6..494156b 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -271,3 +271,38 @@ func TestSetRowHeight(t *testing.T) { t.Log(err) } } + +func TestSetBorder(t *testing.T) { + xlsx, err := OpenFile("./test/Workbook_2.xlsx") + if err != nil { + t.Log(err) + } + // Test set border with invalid style parameter. + err = xlsx.SetBorder("Sheet1", "J21", "L25", "") + if err != nil { + t.Log(err) + } + // Test set border with invalid style index number. + err = xlsx.SetBorder("Sheet1", "J21", "L25", "") + if err != nil { + t.Log(err) + } + // Test set border on overlapping area. + err = xlsx.SetBorder("Sheet1", "J21", "L25", `{"border":[{"type":"left","color":"0000FF","style":-1},{"type":"top","color":"00FF00","style":14},{"type":"bottom","color":"FFFF00","style":5},{"type":"right","color":"FF0000","style":6},{"type":"diagonalDown","color":"A020F0","style":9},{"type":"diagonalUp","color":"A020F0","style":8}]}`) + if err != nil { + t.Log(err) + } + err = xlsx.SetBorder("Sheet1", "M28", "K24", `{"border":[{"type":"left","color":"0000FF","style":2},{"type":"top","color":"00FF00","style":3},{"type":"bottom","color":"FFFF00","style":4},{"type":"right","color":"FF0000","style":5},{"type":"diagonalDown","color":"A020F0","style":6},{"type":"diagonalUp","color":"A020F0","style":7}]}`) + if err != nil { + t.Log(err) + } + // Test set border for a single cell. + err = xlsx.SetBorder("Sheet1", "O22", "O22", `{"border":[{"type":"left","color":"0000FF","style":8},{"type":"top","color":"00FF00","style":9},{"type":"bottom","color":"FFFF00","style":10},{"type":"right","color":"FF0000","style":11},{"type":"diagonalDown","color":"A020F0","style":12},{"type":"diagonalUp","color":"A020F0","style":13}]}`) + if err != nil { + t.Log(err) + } + err = xlsx.Save() + if err != nil { + t.Log(err) + } +} |