diff options
| -rw-r--r-- | datavalidation.go | 12 | ||||
| -rw-r--r-- | datavalidation_test.go | 7 | ||||
| -rw-r--r-- | sheet.go | 18 | ||||
| -rw-r--r-- | xmlWorksheet.go | 8 | 
4 files changed, 19 insertions, 26 deletions
| diff --git a/datavalidation.go b/datavalidation.go index 4b0c4f3..c8c9141 100644 --- a/datavalidation.go +++ b/datavalidation.go @@ -168,16 +168,12 @@ func (dd *DataValidation) SetRange(f1, f2 interface{}, t DataValidationType, o D  //  //     dvRange := excelize.NewDataValidation(true)  //     dvRange.Sqref = "A7:B8" -//     dvRange.SetSqrefDropList("$E$1:$E$3", true) +//     dvRange.SetSqrefDropList("$E$1:$E$3")  //     f.AddDataValidation("Sheet1", dvRange)  // -func (dd *DataValidation) SetSqrefDropList(sqref string, isCurrentSheet bool) error { -	if isCurrentSheet { -		dd.Formula1 = fmt.Sprintf("<formula1>%s</formula1>", sqref) -		dd.Type = convDataValidationType(typeList) -		return nil -	} -	return fmt.Errorf("cross-sheet sqref cell are not supported") +func (dd *DataValidation) SetSqrefDropList(sqref string) { +	dd.Formula1 = fmt.Sprintf("<formula1>%s</formula1>", sqref) +	dd.Type = convDataValidationType(typeList)  }  // SetSqref provides function to set data validation range in drop list. diff --git a/datavalidation_test.go b/datavalidation_test.go index 403cb15..eed1b03 100644 --- a/datavalidation_test.go +++ b/datavalidation_test.go @@ -81,15 +81,12 @@ func TestDataValidationError(t *testing.T) {  	dvRange := NewDataValidation(true)  	dvRange.SetSqref("A7:B8")  	dvRange.SetSqref("A7:B8") -	assert.NoError(t, dvRange.SetSqrefDropList("$E$1:$E$3", true)) - -	err := dvRange.SetSqrefDropList("$E$1:$E$3", false) -	assert.EqualError(t, err, "cross-sheet sqref cell are not supported") +	dvRange.SetSqrefDropList("$E$1:$E$3")  	assert.NoError(t, f.AddDataValidation("Sheet1", dvRange))  	dvRange = NewDataValidation(true) -	err = dvRange.SetDropList(make([]string, 258)) +	err := dvRange.SetDropList(make([]string, 258))  	if dvRange.Formula1 != "" {  		t.Errorf("data validation error. Formula1 must be empty!")  		return @@ -1335,49 +1335,49 @@ func (o *PageLayoutOrientation) getPageLayout(ps *xlsxPageSetUp) {  // setPageLayout provides a method to set the paper size for the worksheet.  func (p PageLayoutPaperSize) setPageLayout(ps *xlsxPageSetUp) { -	ps.PaperSize = int(p) +	ps.PaperSize = intPtr(int(p))  }  // getPageLayout provides a method to get the paper size for the worksheet.  func (p *PageLayoutPaperSize) getPageLayout(ps *xlsxPageSetUp) {  	// Excel default: 1 -	if ps == nil || ps.PaperSize == 0 { +	if ps == nil || ps.PaperSize == nil {  		*p = 1  		return  	} -	*p = PageLayoutPaperSize(ps.PaperSize) +	*p = PageLayoutPaperSize(*ps.PaperSize)  }  // setPageLayout provides a method to set the fit to height for the worksheet.  func (p FitToHeight) setPageLayout(ps *xlsxPageSetUp) {  	if int(p) > 0 { -		ps.FitToHeight = int(p) +		ps.FitToHeight = intPtr(int(p))  	}  }  // getPageLayout provides a method to get the fit to height for the worksheet.  func (p *FitToHeight) getPageLayout(ps *xlsxPageSetUp) { -	if ps == nil || ps.FitToHeight == 0 { +	if ps == nil || ps.FitToHeight == nil {  		*p = 1  		return  	} -	*p = FitToHeight(ps.FitToHeight) +	*p = FitToHeight(*ps.FitToHeight)  }  // setPageLayout provides a method to set the fit to width for the worksheet.  func (p FitToWidth) setPageLayout(ps *xlsxPageSetUp) {  	if int(p) > 0 { -		ps.FitToWidth = int(p) +		ps.FitToWidth = intPtr(int(p))  	}  }  // getPageLayout provides a method to get the fit to width for the worksheet.  func (p *FitToWidth) getPageLayout(ps *xlsxPageSetUp) { -	if ps == nil || ps.FitToWidth == 0 { +	if ps == nil || ps.FitToWidth == nil {  		*p = 1  		return  	} -	*p = FitToWidth(ps.FitToWidth) +	*p = FitToWidth(*ps.FitToWidth)  }  // setPageLayout provides a method to set the scale for the worksheet. diff --git a/xmlWorksheet.go b/xmlWorksheet.go index 5c121d9..649377b 100644 --- a/xmlWorksheet.go +++ b/xmlWorksheet.go @@ -112,16 +112,16 @@ type xlsxPageSetUp struct {  	Draft              bool     `xml:"draft,attr,omitempty"`  	Errors             string   `xml:"errors,attr,omitempty"`  	FirstPageNumber    string   `xml:"firstPageNumber,attr,omitempty"` -	FitToHeight        int      `xml:"fitToHeight,attr,omitempty"` -	FitToWidth         int      `xml:"fitToWidth,attr,omitempty"` +	FitToHeight        *int     `xml:"fitToHeight,attr"` +	FitToWidth         *int     `xml:"fitToWidth,attr,omitempty"`  	HorizontalDPI      int      `xml:"horizontalDpi,attr,omitempty"`  	RID                string   `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`  	Orientation        string   `xml:"orientation,attr,omitempty"`  	PageOrder          string   `xml:"pageOrder,attr,omitempty"`  	PaperHeight        string   `xml:"paperHeight,attr,omitempty"` -	PaperSize          int      `xml:"paperSize,attr,omitempty"` +	PaperSize          *int     `xml:"paperSize,attr,omitempty"`  	PaperWidth         string   `xml:"paperWidth,attr,omitempty"` -	Scale              int      `xml:"scale,attr,omitempty"` +	Scale              int      `xml:"scale,attr"`  	UseFirstPageNumber bool     `xml:"useFirstPageNumber,attr,omitempty"`  	UsePrinterDefaults bool     `xml:"usePrinterDefaults,attr,omitempty"`  	VerticalDPI        int      `xml:"verticalDpi,attr,omitempty"` | 
