Fix UpdateLinkedValue which returns an error when has graph sheet (#793)

* Fixed UpdateLinkedValue which returns an error when there is a graph sheet

Signed-off-by: yuuki.ono <yagfair@gmail.com>

* fix refactoring from review

Signed-off-by: yuuki.ono <yagfair@gmail.com>
This commit is contained in:
yuki2006 2021-03-04 10:23:45 +09:00 committed by GitHub
parent a12dfd3ce6
commit dbe88d723e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -236,6 +236,8 @@ func TestAddChartSheet(t *testing.T) {
// Test with unsupported chart type
assert.EqualError(t, f.AddChartSheet("Chart2", `{"type":"unknown","series":[{"name":"Sheet1!$A$2","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$2:$D$2"},{"name":"Sheet1!$A$3","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$3:$D$3"},{"name":"Sheet1!$A$4","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$4:$D$4"}],"title":{"name":"Fruit 3D Clustered Column Chart"}}`), "unsupported chart type unknown")
assert.NoError(t, f.UpdateLinkedValue())
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddChartSheet.xlsx")))
}

View File

@ -314,6 +314,9 @@ func (f *File) UpdateLinkedValue() error {
for _, name := range f.GetSheetList() {
xlsx, err := f.workSheetReader(name)
if err != nil {
if err.Error() == fmt.Sprintf("sheet %s is chart sheet", trimSheetName(name)) {
continue
}
return err
}
for indexR := range xlsx.SheetData.Row {