forked from p30928647/excelize
This closes #1257, fix incorrect worksheet header footer fields order
This commit is contained in:
parent
7819cd7fec
commit
852f211970
|
@ -234,10 +234,12 @@ func (f *File) workSheetReader(sheet string) (ws *xlsxWorksheet, err error) {
|
||||||
ws = worksheet.(*xlsxWorksheet)
|
ws = worksheet.(*xlsxWorksheet)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(name, "xl/chartsheets") || strings.HasPrefix(name, "xl/macrosheet") {
|
for _, sheetType := range []string{"xl/chartsheets", "xl/dialogsheet", "xl/macrosheet"} {
|
||||||
|
if strings.HasPrefix(name, sheetType) {
|
||||||
err = fmt.Errorf("sheet %s is not a worksheet", sheet)
|
err = fmt.Errorf("sheet %s is not a worksheet", sheet)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ws = new(xlsxWorksheet)
|
ws = new(xlsxWorksheet)
|
||||||
if _, ok := f.xmlAttr[name]; !ok {
|
if _, ok := f.xmlAttr[name]; !ok {
|
||||||
d := f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readBytes(name))))
|
d := f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readBytes(name))))
|
||||||
|
|
2
sheet.go
2
sheet.go
|
@ -280,7 +280,7 @@ func (f *File) SetActiveSheet(index int) {
|
||||||
for idx, name := range f.GetSheetList() {
|
for idx, name := range f.GetSheetList() {
|
||||||
ws, err := f.workSheetReader(name)
|
ws, err := f.workSheetReader(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Chartsheet or dialogsheet
|
// Chartsheet, macrosheet or dialogsheet
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ws.SheetViews == nil {
|
if ws.SheetViews == nil {
|
||||||
|
|
|
@ -22,8 +22,8 @@ import (
|
||||||
type xlsxTypes struct {
|
type xlsxTypes struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/content-types Types"`
|
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/content-types Types"`
|
||||||
Overrides []xlsxOverride `xml:"Override"`
|
|
||||||
Defaults []xlsxDefault `xml:"Default"`
|
Defaults []xlsxDefault `xml:"Default"`
|
||||||
|
Overrides []xlsxOverride `xml:"Override"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// xlsxOverride directly maps the override element in the namespace
|
// xlsxOverride directly maps the override element in the namespace
|
||||||
|
|
|
@ -79,17 +79,16 @@ type xlsxDrawing struct {
|
||||||
// pages. In the latter case, the first page is not considered an odd page.
|
// pages. In the latter case, the first page is not considered an odd page.
|
||||||
type xlsxHeaderFooter struct {
|
type xlsxHeaderFooter struct {
|
||||||
XMLName xml.Name `xml:"headerFooter"`
|
XMLName xml.Name `xml:"headerFooter"`
|
||||||
AlignWithMargins bool `xml:"alignWithMargins,attr,omitempty"`
|
|
||||||
DifferentFirst bool `xml:"differentFirst,attr,omitempty"`
|
|
||||||
DifferentOddEven bool `xml:"differentOddEven,attr,omitempty"`
|
DifferentOddEven bool `xml:"differentOddEven,attr,omitempty"`
|
||||||
|
DifferentFirst bool `xml:"differentFirst,attr,omitempty"`
|
||||||
ScaleWithDoc bool `xml:"scaleWithDoc,attr,omitempty"`
|
ScaleWithDoc bool `xml:"scaleWithDoc,attr,omitempty"`
|
||||||
|
AlignWithMargins bool `xml:"alignWithMargins,attr,omitempty"`
|
||||||
OddHeader string `xml:"oddHeader,omitempty"`
|
OddHeader string `xml:"oddHeader,omitempty"`
|
||||||
OddFooter string `xml:"oddFooter,omitempty"`
|
OddFooter string `xml:"oddFooter,omitempty"`
|
||||||
EvenHeader string `xml:"evenHeader,omitempty"`
|
EvenHeader string `xml:"evenHeader,omitempty"`
|
||||||
EvenFooter string `xml:"evenFooter,omitempty"`
|
EvenFooter string `xml:"evenFooter,omitempty"`
|
||||||
FirstFooter string `xml:"firstFooter,omitempty"`
|
|
||||||
FirstHeader string `xml:"firstHeader,omitempty"`
|
FirstHeader string `xml:"firstHeader,omitempty"`
|
||||||
DrawingHF *xlsxDrawingHF `xml:"drawingHF"`
|
FirstFooter string `xml:"firstFooter,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// xlsxDrawingHF (Drawing Reference in Header Footer) specifies the usage of
|
// xlsxDrawingHF (Drawing Reference in Header Footer) specifies the usage of
|
||||||
|
@ -147,12 +146,12 @@ type xlsxPrintOptions struct {
|
||||||
// a sheet or a custom sheet view.
|
// a sheet or a custom sheet view.
|
||||||
type xlsxPageMargins struct {
|
type xlsxPageMargins struct {
|
||||||
XMLName xml.Name `xml:"pageMargins"`
|
XMLName xml.Name `xml:"pageMargins"`
|
||||||
Bottom float64 `xml:"bottom,attr"`
|
|
||||||
Footer float64 `xml:"footer,attr"`
|
|
||||||
Header float64 `xml:"header,attr"`
|
|
||||||
Left float64 `xml:"left,attr"`
|
Left float64 `xml:"left,attr"`
|
||||||
Right float64 `xml:"right,attr"`
|
Right float64 `xml:"right,attr"`
|
||||||
Top float64 `xml:"top,attr"`
|
Top float64 `xml:"top,attr"`
|
||||||
|
Bottom float64 `xml:"bottom,attr"`
|
||||||
|
Header float64 `xml:"header,attr"`
|
||||||
|
Footer float64 `xml:"footer,attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// xlsxSheetFormatPr directly maps the sheetFormatPr element in the namespace
|
// xlsxSheetFormatPr directly maps the sheetFormatPr element in the namespace
|
||||||
|
@ -880,8 +879,8 @@ type FormatHeaderFooter struct {
|
||||||
OddFooter string
|
OddFooter string
|
||||||
EvenHeader string
|
EvenHeader string
|
||||||
EvenFooter string
|
EvenFooter string
|
||||||
FirstFooter string
|
|
||||||
FirstHeader string
|
FirstHeader string
|
||||||
|
FirstFooter string
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatPageMargins directly maps the settings of page margins
|
// FormatPageMargins directly maps the settings of page margins
|
||||||
|
|
Loading…
Reference in New Issue