MCPcopy
hub / github.com/qax-os/excelize / Flush

Method Flush

stream.go:748–775  ·  view source on GitHub ↗

Flush ending the streaming writing process.

()

Source from the content-addressed store, hash-verified

746
747// Flush ending the streaming writing process.
748func (sw *StreamWriter) Flush() error {
749 sw.writeSheetData()
750 _, _ = sw.rawData.WriteString(`</sheetData>`)
751 bulkAppendFields(&sw.rawData, sw.worksheet, 9, 16)
752 mergeCells := strings.Builder{}
753 if sw.mergeCellsCount > 0 {
754 _, _ = mergeCells.WriteString(`<mergeCells count="`)
755 _, _ = mergeCells.WriteString(strconv.Itoa(sw.mergeCellsCount))
756 _, _ = mergeCells.WriteString(`">`)
757 _, _ = mergeCells.WriteString(sw.mergeCells.String())
758 _, _ = mergeCells.WriteString(`</mergeCells>`)
759 }
760 _, _ = sw.rawData.WriteString(mergeCells.String())
761 bulkAppendFields(&sw.rawData, sw.worksheet, 18, 39)
762 _, _ = sw.rawData.WriteString(sw.tableParts)
763 bulkAppendFields(&sw.rawData, sw.worksheet, 41, 41)
764 _, _ = sw.rawData.WriteString(`</worksheet>`)
765 if err := sw.rawData.Flush(); err != nil {
766 return err
767 }
768
769 sheetPath := sw.file.sheetMap[sw.Sheet]
770 sw.file.Sheet.Delete(sheetPath)
771 sw.file.checked.Delete(sheetPath)
772 sw.file.Pkg.Delete(sheetPath)
773
774 return nil
775}
776
777// bulkAppendFields bulk-appends fields in a worksheet by specified field
778// names order range.

Callers 13

TestZip64Function · 0.95
TestStreamWriterFunction · 0.95
TestStreamSetColVisibleFunction · 0.95
TestStreamSetColWidthFunction · 0.95
TestStreamTableFunction · 0.95
TestStreamMergeCellsFunction · 0.95

Calls 4

writeSheetDataMethod · 0.95
bulkAppendFieldsFunction · 0.85
WriteStringMethod · 0.80
StringMethod · 0.80

Tested by 13

TestZip64Function · 0.76
TestStreamWriterFunction · 0.76
TestStreamSetColVisibleFunction · 0.76
TestStreamSetColWidthFunction · 0.76
TestStreamTableFunction · 0.76
TestStreamMergeCellsFunction · 0.76