mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 00:02:50 +08:00
完善excel2导出
This commit is contained in:
@@ -26,15 +26,11 @@ func GetExcelData(file multipart.File, dst interface{}, cols []Col) (err error)
|
||||
// 创建Excel文件对象
|
||||
f, err := excelize.OpenReader(bytes.NewReader(buf.Bytes()))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
// c.String(http.StatusInternalServerError, "Excel读取失败")
|
||||
err = errors.New("Excel读取失败")
|
||||
return
|
||||
}
|
||||
err = ImportExcel(f, dst, 2, cols)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -60,16 +56,6 @@ func ImportBySheet(f *excelize.File, dst interface{}, sheetName string, startRow
|
||||
return
|
||||
}
|
||||
|
||||
// 获取在数组中得下标
|
||||
func GetIndex(items []string, item string) int {
|
||||
for i, v := range items {
|
||||
if v == item {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// 解析数据
|
||||
func importData(f *excelize.File, dst interface{}, sheetName string, startRow int, cols []Col) (err error) {
|
||||
rows, err := f.GetRows(sheetName) // 获取所有行
|
||||
|
Reference in New Issue
Block a user