feature/excel #2
@ -140,5 +140,35 @@ func (r *Read) ExtractAssignCol(colIndexList []int) (map[string][][]string, erro
|
|||||||
//
|
//
|
||||||
// Date : 4:53 下午 2021/11/19
|
// Date : 4:53 下午 2021/11/19
|
||||||
func (r *Read) ExtractAssignColToMap(ruleTable map[int]string) (map[string][]map[string]string, error) {
|
func (r *Read) ExtractAssignColToMap(ruleTable map[int]string) (map[string][]map[string]string, error) {
|
||||||
return nil, nil
|
var (
|
||||||
|
allData map[string][][]string
|
||||||
|
err error
|
||||||
|
formatResult map[string][]map[string]string
|
||||||
|
)
|
||||||
|
formatResult = make(map[string][]map[string]string)
|
||||||
|
if allData, err = r.GetAllData(); nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for sheetName, sheetData := range allData {
|
||||||
|
formatResult[sheetName] = make([]map[string]string, 0)
|
||||||
|
for _, lineData := range sheetData {
|
||||||
|
tmpResult := make(map[string]string)
|
||||||
|
for idx, colData := range lineData {
|
||||||
|
colName, exist := ruleTable[idx]
|
||||||
|
if !exist {
|
||||||
|
// 当前字段不需要提取
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tmpResult[colName] = colData
|
||||||
|
}
|
||||||
|
for _, colName := range ruleTable {
|
||||||
|
if _, exist := tmpResult[colName]; !exist {
|
||||||
|
tmpResult[colName] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
formatResult[sheetName] = append(formatResult[sheetName], tmpResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 格式化数据
|
||||||
|
return formatResult, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user