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.
- Loading branch information
Showing
16 changed files
with
438 additions
and
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package excelize | ||
|
||
import "testing" | ||
|
||
func TestCalcChainReader(t *testing.T) { | ||
f := NewFile() | ||
f.CalcChain = nil | ||
f.XLSX["xl/calcChain.xml"] = MacintoshCyrillicCharset | ||
f.calcChainReader() | ||
} | ||
|
||
func TestDeleteCalcChain(t *testing.T) { | ||
f := NewFile() | ||
f.CalcChain = &xlsxCalcChain{C: []xlsxCalcChainC{}} | ||
f.ContentTypes.Overrides = append(f.ContentTypes.Overrides, xlsxOverride{ | ||
PartName: "/xl/calcChain.xml", | ||
}) | ||
f.deleteCalcChain(1, "A1") | ||
} |
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,56 @@ | ||
// Copyright 2016 - 2019 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.10 or later. | ||
|
||
package excelize | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAddComments(t *testing.T) { | ||
f, err := prepareTestBook1() | ||
if !assert.NoError(t, err) { | ||
t.FailNow() | ||
} | ||
|
||
s := strings.Repeat("c", 32768) | ||
assert.NoError(t, f.AddComment("Sheet1", "A30", `{"author":"`+s+`","text":"`+s+`"}`)) | ||
assert.NoError(t, f.AddComment("Sheet2", "B7", `{"author":"Excelize: ","text":"This is a comment."}`)) | ||
|
||
// Test add comment on not exists worksheet. | ||
assert.EqualError(t, f.AddComment("SheetN", "B7", `{"author":"Excelize: ","text":"This is a comment."}`), "sheet SheetN is not exist") | ||
|
||
if assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddComments.xlsx"))) { | ||
assert.Len(t, f.GetComments(), 2) | ||
} | ||
} | ||
|
||
func TestDecodeVMLDrawingReader(t *testing.T) { | ||
f := NewFile() | ||
path := "xl/drawings/vmlDrawing1.xml" | ||
f.XLSX[path] = MacintoshCyrillicCharset | ||
f.decodeVMLDrawingReader(path) | ||
} | ||
|
||
func TestCommentsReader(t *testing.T) { | ||
f := NewFile() | ||
path := "xl/comments1.xml" | ||
f.XLSX[path] = MacintoshCyrillicCharset | ||
f.commentsReader(path) | ||
} | ||
|
||
func TestCountComments(t *testing.T) { | ||
f := NewFile() | ||
f.Comments["xl/comments1.xml"] = nil | ||
assert.Equal(t, f.countComments(), 1) | ||
} |
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
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
Oops, something went wrong.