fix custom row height check issue
This commit is contained in:
parent
2fb135bc94
commit
30549c5e90
2
rows.go
2
rows.go
|
@ -290,7 +290,7 @@ func (f *File) GetRowHeight(sheet string, row int) (float64, error) {
|
|||
if err != nil {
|
||||
return ht, err
|
||||
}
|
||||
if ws.SheetFormatPr != nil {
|
||||
if ws.SheetFormatPr != nil && ws.SheetFormatPr.CustomHeight {
|
||||
ht = ws.SheetFormatPr.DefaultRowHeight
|
||||
}
|
||||
if row > len(ws.SheetData.Row) {
|
||||
|
|
12
rows_test.go
12
rows_test.go
|
@ -126,6 +126,18 @@ func TestRowHeight(t *testing.T) {
|
|||
_, err = f.GetRowHeight("SheetN", 3)
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
|
||||
// Test get row height with custom default row height.
|
||||
assert.NoError(t, f.SetSheetFormatPr(sheet1,
|
||||
DefaultRowHeight(30.0),
|
||||
CustomHeight(true),
|
||||
))
|
||||
height, err = f.GetRowHeight(sheet1, 100)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 30.0, height)
|
||||
|
||||
// Test set row height with custom default row height with prepare XML.
|
||||
assert.NoError(t, f.SetCellValue(sheet1, "A10", "A10"))
|
||||
|
||||
err = f.SaveAs(filepath.Join("test", "TestRowHeight.xlsx"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
|
|
10
sheet.go
10
sheet.go
|
@ -860,18 +860,18 @@ func (f *File) searchSheet(name, value string, regSearch bool) (result []string,
|
|||
}
|
||||
break
|
||||
}
|
||||
switch startElement := token.(type) {
|
||||
switch xmlElement := token.(type) {
|
||||
case xml.StartElement:
|
||||
inElement = startElement.Name.Local
|
||||
inElement = xmlElement.Name.Local
|
||||
if inElement == "row" {
|
||||
row, err = attrValToInt("r", startElement.Attr)
|
||||
row, err = attrValToInt("r", xmlElement.Attr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
if inElement == "c" {
|
||||
colCell := xlsxC{}
|
||||
_ = decoder.DecodeElement(&colCell, &startElement)
|
||||
_ = decoder.DecodeElement(&colCell, &xmlElement)
|
||||
val, _ := colCell.getValueFrom(f, d)
|
||||
if regSearch {
|
||||
regex := regexp.MustCompile(value)
|
||||
|
@ -1745,7 +1745,7 @@ func prepareSheetXML(ws *xlsxWorksheet, col int, row int) {
|
|||
sizeHint := 0
|
||||
var ht float64
|
||||
var customHeight bool
|
||||
if ws.SheetFormatPr != nil {
|
||||
if ws.SheetFormatPr != nil && ws.SheetFormatPr.CustomHeight {
|
||||
ht = ws.SheetFormatPr.DefaultRowHeight
|
||||
customHeight = true
|
||||
}
|
||||
|
|
|
@ -169,6 +169,7 @@ func (f *File) getSheetView(sheet string, viewIndex int) (*xlsxSheetView, error)
|
|||
// ShowRowColHeaders(bool)
|
||||
// ZoomScale(float64)
|
||||
// TopLeftCell(string)
|
||||
// ShowZeros(bool)
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
|
@ -198,6 +199,7 @@ func (f *File) SetSheetViewOptions(name string, viewIndex int, opts ...SheetView
|
|||
// ShowRowColHeaders(bool)
|
||||
// ZoomScale(float64)
|
||||
// TopLeftCell(string)
|
||||
// ShowZeros(bool)
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
|
|
|
@ -37,8 +37,9 @@ type StreamWriter struct {
|
|||
// NewStreamWriter return stream writer struct by given worksheet name for
|
||||
// generate new worksheet with large amounts of data. Note that after set
|
||||
// rows, you must call the 'Flush' method to end the streaming writing
|
||||
// process and ensure that the order of line numbers is ascending. For
|
||||
// example, set data for worksheet of size 102400 rows x 50 columns with
|
||||
// process and ensure that the order of line numbers is ascending, the common
|
||||
// API and stream API can't be work mixed to writing data on the worksheets.
|
||||
// For example, set data for worksheet of size 102400 rows x 50 columns with
|
||||
// numbers and style:
|
||||
//
|
||||
// file := excelize.NewFile()
|
||||
|
|
Loading…
Reference in New Issue