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 }