diff --git a/rows.go b/rows.go index 702d8f5..75bea47 100644 --- a/rows.go +++ b/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) { diff --git a/rows_test.go b/rows_test.go index 0e250f6..0180498 100644 --- a/rows_test.go +++ b/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() diff --git a/sheet.go b/sheet.go index bb94f6a..0d6f5d1 100644 --- a/sheet.go +++ b/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 } diff --git a/sheetview.go b/sheetview.go index a942fb4..0a8fd5c 100644 --- a/sheetview.go +++ b/sheetview.go @@ -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: // diff --git a/stream.go b/stream.go index bbb1ec1..e2f7935 100644 --- a/stream.go +++ b/stream.go @@ -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()