From 2df615fa2831bd578371d4e3606f16461c474ce7 Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 20 Oct 2022 00:02:30 +0800 Subject: This close #1373, fixes the incorrect build-in number format apply the result - An error will be returned when setting the stream row without ascending row numbers, to avoid potential mistakes as mentioned in #1139 - Updated unit tests --- stream.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'stream.go') diff --git a/stream.go b/stream.go index 62470b5..44d8eb7 100644 --- a/stream.go +++ b/stream.go @@ -32,6 +32,7 @@ type StreamWriter struct { cols strings.Builder worksheet *xlsxWorksheet rawData bufferedWriter + rows int mergeCellsCount int mergeCells strings.Builder tableParts string @@ -40,7 +41,7 @@ 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, the normal mode +// and ensure that the order of row numbers is ascending, the normal mode // functions and stream mode functions can't be work mixed to writing data on // the worksheets, you can't get cell value when in-memory chunks data over // 16MB. For example, set data for worksheet of size 102400 rows x 50 columns @@ -358,6 +359,10 @@ func (sw *StreamWriter) SetRow(cell string, values []interface{}, opts ...RowOpt if err != nil { return err } + if row <= sw.rows { + return newStreamSetRowError(row) + } + sw.rows = row sw.writeSheetData() options := parseRowOpts(opts...) attrs, err := options.marshalAttrs() -- cgit v1.2.1