From 915d474feab194ea294198ec1ae26faefe4395dd Mon Sep 17 00:00:00 2001 From: ayflying Date: Wed, 26 Feb 2025 12:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=AF=BC=E8=A1=A8=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=86=92=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- excel/excel.go | 8 +++++++- excel/tools.go | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/excel/excel.go b/excel/excel.go index 636bd2a..85cfc19 100644 --- a/excel/excel.go +++ b/excel/excel.go @@ -16,6 +16,10 @@ import ( "time" ) +var ( + shadiao = []string{",", ":"} +) + type FileItem struct { Name string `json:"name" dc:"配置文件名"` Filename string `json:"filename" dc:"文件名"` @@ -131,7 +135,6 @@ func (s *Excel) sliceFormat(list []interface{}, Slice map[string]string) []inter list[k2].(g.Map)[k3] = []string{} continue } - var parts []string //断言是否成功 if get, ok := v3.(string); !ok { @@ -139,6 +142,9 @@ func (s *Excel) sliceFormat(list []interface{}, Slice map[string]string) []inter parts = []string{gconv.String(v3)} continue } else { + for _, v := range shadiao { + get = strings.ReplaceAll(get, v, "|") + } parts = strings.Split(get, "|") // 分割字符串 } diff --git a/excel/tools.go b/excel/tools.go index 88f2e77..ba89841 100644 --- a/excel/tools.go +++ b/excel/tools.go @@ -27,7 +27,6 @@ func Excel2Slice(filePath string, _sheet ...string) [][]string { // 字符串转道具类型 func Spilt2Item(str string) (result [][]int64) { - var shadiao = []string{","} for _, v := range shadiao { str = strings.ReplaceAll(str, v, "|") //parts = append(parts, strings.Split(str, v)...) // 分割字符串