From 84b81fb98c4c50322e59ce001ef56705c6636e77 Mon Sep 17 00:00:00 2001 From: "Mr.Li" Date: Tue, 11 Apr 2023 15:08:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=8E=B7=E5=8F=96=E5=88=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- biz/export/excel_exporter.go | 5 +++-- cmd/cmd/excel.go | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/biz/export/excel_exporter.go b/biz/export/excel_exporter.go index d4924c0..aa1aa32 100644 --- a/biz/export/excel_exporter.go +++ b/biz/export/excel_exporter.go @@ -42,8 +42,9 @@ func (ee *ExcelExporter) Export(sql, pk string) error { ee.file.Write(last) } - ee.last = last[getPkIndex(data.Title, pk)] - + if len(last) > 0 { + ee.last = last[getPkIndex(data.Title, pk)] + } //ee.file.Close() return nil } diff --git a/cmd/cmd/excel.go b/cmd/cmd/excel.go index e0d2a56..ee3db20 100644 --- a/cmd/cmd/excel.go +++ b/cmd/cmd/excel.go @@ -66,6 +66,11 @@ func (e *Excel) TaskExport(d export.DataFetcher, t config.Task, params map[strin count, last := e.Last() fmt.Printf("已导出 %d 条数据\n", batch*i+count) + + if count == 0 { + return nil + } + if count < batch { break }