|
@@ -8,6 +8,7 @@ import (
|
|
|
"net/url"
|
|
|
"regexp"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
|
|
|
"github.com/xuri/excelize/v2"
|
|
|
)
|
|
@@ -155,7 +156,11 @@ func ProcessKplerData(filePath string) (indexData []models.KplerExcelIndexData,
|
|
|
if len(data.Rows) < 3 {
|
|
|
return nil, fmt.Errorf("Excel file does not have enough rows")
|
|
|
}
|
|
|
-
|
|
|
+ titles := data.Headers
|
|
|
+ titleMap := make(map[int]string)
|
|
|
+ for j, title := range titles {
|
|
|
+ titleMap[j] = title
|
|
|
+ }
|
|
|
headers := data.Rows[1] // Get headers from the second row
|
|
|
fmt.Println("Headers:", headers)
|
|
|
|
|
@@ -207,6 +212,22 @@ func ProcessKplerData(filePath string) (indexData []models.KplerExcelIndexData,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 获取标题
|
|
|
+
|
|
|
+ title, ok := titleMap[j]
|
|
|
+ if ok && title != "" {
|
|
|
+ indexMap[j].Title = title
|
|
|
+ }else{
|
|
|
+ // Look backwards for the formula
|
|
|
+ for k := j; k >= 0; k-- {
|
|
|
+ title, ok := titleMap[k]
|
|
|
+ if ok && title != "" {
|
|
|
+ indexMap[j].Title = title
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -232,7 +253,14 @@ func ProcessKplerData(filePath string) (indexData []models.KplerExcelIndexData,
|
|
|
|
|
|
// If this is a date column, store its values
|
|
|
if _, exists := dateValues[j]; exists {
|
|
|
- dateValues[j] = append(dateValues[j], cell)
|
|
|
+ // 对日期进行格式化
|
|
|
+ dateFormat := "01-02-06"
|
|
|
+ date, err := time.Parse(dateFormat, cell)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error parsing date:", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ dateValues[j] = append(dateValues[j], date.Format(utils.FormatDate))
|
|
|
continue
|
|
|
}
|
|
|
|