#1 all ratings are maped

This commit is contained in:
Andreas Schröpfer
2021-02-28 11:04:15 +01:00
parent 90af0db862
commit d310fdd2b3
6 changed files with 3312 additions and 65 deletions

View File

@@ -94,6 +94,52 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
}
}
var topic ecalc.Topic
for r := conf.Rating.StartRow; r <= conf.Rating.EndRow; r++ {
shortName, err := xFile.GetCellValue(
xFile.GetSheetName(conf.Rating.Sheet),
fmt.Sprintf("%s%d", conf.Rating.ShortNameCol, r),
)
if err != nil {
errs = append(errs, err)
}
if len(shortName) < 2 {
continue
} else if len(shortName) == 2 {
if topic.ShortName != "" {
eBalance.CompanyFacts.Rating.Topics = append(eBalance.CompanyFacts.Rating.Topics, topic)
}
topic = ecalc.Topic{
ShortName: shortName,
}
for _, c := range conf.Rating.Cols {
cellValue, err := xFile.GetCellValue(
xFile.GetSheetName(conf.Rating.Sheet),
fmt.Sprintf("%s%d", c.Col, r),
)
if err != nil {
errs = append(errs, err)
}
set.Field(&topic, c.Field, cellValue)
}
} else {
aspect := ecalc.Aspect{
ShortName: shortName,
}
for _, c := range conf.Rating.Cols {
cellValue, err := xFile.GetCellValue(
xFile.GetSheetName(conf.Rating.Sheet),
fmt.Sprintf("%s%d", c.Col, r),
)
if err != nil {
errs = append(errs, err)
}
set.Field(&aspect, c.Field, cellValue)
}
topic.Aspects = append(topic.Aspects, aspect)
}
}
eBalance.CompanyFacts.Rating.Topics = append(eBalance.CompanyFacts.Rating.Topics, topic)
// TODO: error handling of errs
return eBalance, nil
}