@@ -75,6 +75,7 @@ type AreaCol struct {
|
||||
Col string `json:"col"`
|
||||
Field string `json:"field"`
|
||||
Type string `json:"type"`
|
||||
Split string `json:"split"`
|
||||
Default string `json:"default"`
|
||||
}
|
||||
|
||||
|
||||
@@ -119,12 +119,14 @@
|
||||
"col": "B",
|
||||
"field": "IndustryCode",
|
||||
"type": "string",
|
||||
"split": " ",
|
||||
"default": "Please choose"
|
||||
},
|
||||
{
|
||||
"col": "D",
|
||||
"field": "CountryCode",
|
||||
"type": "string",
|
||||
"split": " ",
|
||||
"default": "Please choose"
|
||||
},
|
||||
{
|
||||
@@ -145,6 +147,7 @@
|
||||
"col": "B",
|
||||
"field": "CountryCode",
|
||||
"type": "string",
|
||||
"split": " ",
|
||||
"default": "Please choose"
|
||||
},
|
||||
{
|
||||
@@ -165,7 +168,8 @@
|
||||
"col": "B",
|
||||
"field": "IndustryCode",
|
||||
"type": "string",
|
||||
"default": "Please choose"
|
||||
"split": " ",
|
||||
"default": "Please choose"
|
||||
},
|
||||
{
|
||||
"col": "C",
|
||||
|
||||
@@ -3,6 +3,7 @@ package loader
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"git.ecogood.org/andreas.schroepfer/excelConverter/pkg/ecalc"
|
||||
"git.ecogood.org/andreas.schroepfer/excelConverter/pkg/set"
|
||||
@@ -46,11 +47,15 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
||||
axis := fmt.Sprintf("%s%d", c.Col, r)
|
||||
cellValue, err := xFile.GetCellValue(
|
||||
xFile.GetSheetName(a.Sheet),
|
||||
axis,
|
||||
)
|
||||
axis)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if cellValue == c.Default {
|
||||
continue
|
||||
} else if c.Split != "" {
|
||||
cellValue = strings.Split(cellValue, c.Split)[0]
|
||||
}
|
||||
err = set.Field(&sf, c.Field, cellValue)
|
||||
if err != nil {
|
||||
errs = append(errs,
|
||||
@@ -58,6 +63,10 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
||||
a.Sheet, axis, err))
|
||||
}
|
||||
}
|
||||
if (sf == ecalc.SupplyFraction{}) {
|
||||
// do not add a empty struct
|
||||
continue
|
||||
}
|
||||
eBalance.CompanyFacts.SupplyFractions =
|
||||
append(
|
||||
eBalance.CompanyFacts.SupplyFractions,
|
||||
@@ -67,14 +76,28 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
||||
for r := a.StartRow; r <= a.EndRow; r++ {
|
||||
ef := ecalc.EmployeesFraction{}
|
||||
for _, c := range a.Cols {
|
||||
axis := fmt.Sprintf("%s%d", c.Col, r)
|
||||
cellValue, err := xFile.GetCellValue(
|
||||
xFile.GetSheetName(a.Sheet),
|
||||
fmt.Sprintf("%s%d", c.Col, r),
|
||||
)
|
||||
axis)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
set.Field(&ef, c.Field, cellValue)
|
||||
if cellValue == c.Default {
|
||||
continue
|
||||
} else if c.Split != "" {
|
||||
cellValue = strings.Split(cellValue, c.Split)[0]
|
||||
}
|
||||
err = set.Field(&ef, c.Field, cellValue)
|
||||
if err != nil {
|
||||
errs = append(errs,
|
||||
fmt.Errorf("XLSXL.EmployeesFraction: Sheet %d, Cell %s: %w",
|
||||
a.Sheet, axis, err))
|
||||
}
|
||||
}
|
||||
if (ef == ecalc.EmployeesFraction{}) {
|
||||
// do not add a empty struct
|
||||
continue
|
||||
}
|
||||
eBalance.CompanyFacts.EmployeesFractions =
|
||||
append(
|
||||
@@ -85,14 +108,28 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
|
||||
for r := a.StartRow; r <= a.EndRow; r++ {
|
||||
is := ecalc.IndustrySector{}
|
||||
for _, c := range a.Cols {
|
||||
axis := fmt.Sprintf("%s%d", c.Col, r)
|
||||
cellValue, err := xFile.GetCellValue(
|
||||
xFile.GetSheetName(a.Sheet),
|
||||
fmt.Sprintf("%s%d", c.Col, r),
|
||||
)
|
||||
axis)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
set.Field(&is, c.Field, cellValue)
|
||||
if cellValue == c.Default {
|
||||
continue
|
||||
} else if c.Split != "" {
|
||||
cellValue = strings.Split(cellValue, c.Split)[0]
|
||||
}
|
||||
err = set.Field(&is, c.Field, cellValue)
|
||||
if err != nil {
|
||||
errs = append(errs,
|
||||
fmt.Errorf("XLSXL.IndustrySector: Sheet %d, Cell %s: %w",
|
||||
a.Sheet, axis, err))
|
||||
}
|
||||
}
|
||||
if (is == ecalc.IndustrySector{}) {
|
||||
// do not add a empty struct
|
||||
continue
|
||||
}
|
||||
eBalance.CompanyFacts.IndustrySectors =
|
||||
append(
|
||||
|
||||
Reference in New Issue
Block a user