diff options
author | xuri <xuri.me@gmail.com> | 2020-09-01 00:40:56 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-09-01 00:47:44 +0800 |
commit | 4177c1585e312bee00c1592af3df6423c366e806 (patch) | |
tree | a249e1531eeca4b1df5278bde206c4697ed7eee2 /excelize_test.go | |
parent | 88de2f8d510b0959bbb672b80656d207bd0bc927 (diff) |
Resolve #199, init password protection spreadsheet support
Diffstat (limited to 'excelize_test.go')
-rw-r--r-- | excelize_test.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/excelize_test.go b/excelize_test.go index c2bd3ad..923e4c5 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -201,14 +201,14 @@ func TestCharsetTranscoder(t *testing.T) { func TestOpenReader(t *testing.T) { _, err := OpenReader(strings.NewReader("")) assert.EqualError(t, err, "zip: not a valid zip file") - _, err = OpenReader(bytes.NewReader([]byte{ - 0x3c, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x73, 0x00, - 0x6f, 0x00, 0x66, 0x00, 0x74, 0x00, 0x2e, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00, - 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x72, 0x00, 0x2e, 0x00, 0x44, 0x00, 0x61, 0x00, - 0x74, 0x00, 0x61, 0x00, 0x53, 0x00, 0x70, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00, 0x73, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - })) - assert.EqualError(t, err, "not support encrypted file currently") + _, err = OpenReader(bytes.NewReader(cryptoIdentifier)) + assert.EqualError(t, err, "decrypted file failed") + + f, err := OpenFile(filepath.Join("test", "encryptSHA1.xlsx"), Options{Password: "password"}) + assert.NoError(t, err) + val, err := f.GetCellValue("Sheet1", "A1") + assert.NoError(t, err) + assert.Equal(t, "SECRET", val) // Test unexpected EOF. var b bytes.Buffer |