Skip to content

Commit

Permalink
Simplify code and update unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuri committed Aug 1, 2017
1 parent b327eb5 commit 6626a26
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 35 deletions.
3 changes: 3 additions & 0 deletions excelize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ func TestGetPicture(t *testing.T) {
// Try to get picture from a cell that doesn't contain an image.
file, raw = xlsx.GetPicture("Sheet2", "A2")
t.Log(file, len(raw))
xlsx.getDrawingRelationships("xl/worksheets/_rels/sheet1.xml.rels", "rId8")
xlsx.getDrawingRelationships("", "")
xlsx.getSheetRelationshipsTargetByID("", "")
}

func TestSheetVisibility(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,10 @@ func (f *File) SetPanes(sheet, panes string) {
// xlsx.GetSheetVisible("Sheet1")
//
func (f *File) GetSheetVisible(name string) bool {
name = trimSheetName(name)
content := f.workbookReader()
visible := false
for k, v := range content.Sheets.Sheet {
if v.Name == name {
if v.Name == trimSheetName(name) {
if content.Sheets.Sheet[k].State == "" || content.Sheets.Sheet[k].State == "visible" {
visible = true
}
Expand Down
4 changes: 2 additions & 2 deletions templates.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file contains default templates for XML files we don't yet
// populated based on content.
// This file contains default templates for XML files we don't yet populated
// based on content.

package excelize

Expand Down
52 changes: 21 additions & 31 deletions xmlChart.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,7 @@ type formatChartAxis struct {
Italic bool `json:"italic"`
Underline bool `json:"underline"`
} `json:"num_font"`
NameLayout struct {
X float64 `json:"x"`
Y float64 `json:"y"`
} `json:"name_layout"`
NameLayout formatLayout `json:"name_layout"`
}

// formatChart directly maps the format settings of the chart.
Expand Down Expand Up @@ -537,12 +534,7 @@ type formatChart struct {
Fill struct {
Color string `json:"color"`
} `json:"fill"`
Layout struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
} `json:"layout"`
Layout formatLayout `json:"layout"`
} `json:"plotarea"`
ShowBlanksAs string `json:"show_blanks_as"`
ShowHiddenData bool `json:"show_hidden_data"`
Expand All @@ -552,18 +544,13 @@ type formatChart struct {

// formatChartLegend directly maps the format settings of the chart legend.
type formatChartLegend struct {
None bool `json:"none"`
DeleteSeries []int `json:"delete_series"`
Font formatFont `json:"font"`
Layout struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
} `json:"layout"`
Position string `json:"position"`
ShowLegendEntry bool `json:"show_legend_entry"`
ShowLegendKey bool `json:"show_legend_key"`
None bool `json:"none"`
DeleteSeries []int `json:"delete_series"`
Font formatFont `json:"font"`
Layout formatLayout `json:"layout"`
Position string `json:"position"`
ShowLegendEntry bool `json:"show_legend_entry"`
ShowLegendKey bool `json:"show_legend_key"`
}

// formatChartSeries directly maps the format settings of the chart series.
Expand Down Expand Up @@ -592,13 +579,16 @@ type formatChartSeries struct {

// formatChartTitle directly maps the format settings of the chart title.
type formatChartTitle struct {
None bool `json:"none"`
Name string `json:"name"`
Overlay bool `json:"overlay"`
Layout struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
} `json:"layout"`
None bool `json:"none"`
Name string `json:"name"`
Overlay bool `json:"overlay"`
Layout formatLayout `json:"layout"`
}

// formatLayout directly maps the format settings of the element layout.
type formatLayout struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
}

0 comments on commit 6626a26

Please sign in to comment.