限制单表最大数据为100w

This commit is contained in:
Mr.Li 2023-04-21 18:23:57 +08:00
parent 1348673a38
commit 14931a9ea6
1 changed files with 7 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/xuri/excelize/v2"
"io"
"log"
"math"
"os"
"regexp"
"strconv"
@ -131,7 +132,7 @@ func (m *Merge) reset() (err error) {
func (m *Merge) count() {
m.total++
m.rowIndex++
if m.rowIndex > m.writer.Limit {
if m.rowIndex > m.writer.GetLimit() {
m.reset()
}
}
@ -173,6 +174,11 @@ func (w *Writer) GetFileName(fileIndex int) string {
return string(name)
}
func (w *Writer) GetLimit() int {
//excel 单表最大100w行数据
return int(math.Min(float64(w.Limit), 1000000))
}
func transform(record []string) []interface{} {
result := make([]interface{}, len(record))
for i2, s := range record {