Flush ending the streaming writing process.
()
| 746 | |
| 747 | // Flush ending the streaming writing process. |
| 748 | func (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. |