diff --git a/dice/dice_help.go b/dice/dice_help.go index 1904158e..b98b95f0 100644 --- a/dice/dice_help.go +++ b/dice/dice_help.go @@ -277,11 +277,20 @@ func (m *HelpManager) loadHelpDoc(group string, path string) bool { break } - for _, s := range f.GetSheetList() { + for index, s := range f.GetSheetList() { rows, err := f.GetRows(s) if err == nil { - for _, row := range rows { - // Keys Synonym Content Description Catalogue Tag + for i, row := range rows { + if i == 0 { + err := checkXlsxHeaders(row) + if err == nil { + // 跳过第一行 + continue + } else { + fmt.Printf("%s sheet %d: %s\n", path, index, err) + break + } + } if len(row) < 3 { continue } @@ -313,6 +322,20 @@ func (m *HelpManager) loadHelpDoc(group string, path string) bool { return false } +// checkXlsxHeaders 验证 xlsx 格式 helpdoc 的表头是否是 Key Synonym Content Description Catalogue Tag +func checkXlsxHeaders(headers []string) error { + if len(headers) == 6 && + headers[0] == "Key" && + headers[1] == "Synonym" && + headers[2] == "Content" && + headers[3] == "Description" && + headers[4] == "Catalogue" && + headers[5] == "Tag" { + return nil + } + return fmt.Errorf("helpdoc表头格式错误") +} + func (dm *DiceManager) AddHelpWithDice(dice *Dice) { m := dm.Help