diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-08-05 20:36:41 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-08-05 20:36:41 +0100 |
commit | e913fe28e7f9009ff18194dd5cece3eae067a7c4 (patch) | |
tree | 794f1111014a1921f5888915710ac7c1bfacdfe3 /pkg/datamaps/db.go | |
parent | bc795edf4ff146d204aa08786572e27d4323866d (diff) |
debugging numberformat issues
Diffstat (limited to 'pkg/datamaps/db.go')
-rw-r--r-- | pkg/datamaps/db.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pkg/datamaps/db.go b/pkg/datamaps/db.go index 80724ce..d95bfd7 100644 --- a/pkg/datamaps/db.go +++ b/pkg/datamaps/db.go @@ -49,6 +49,7 @@ func setupDB(path string) (*sql.DB, error) { filename TEXT, value TEXT, numfmt TEXT, + vFormatted TEXT, FOREIGN KEY (dml_id) REFERENCES datamap_line(id) ON DELETE CASCADE @@ -236,14 +237,18 @@ func importXLSXtoDB(dmName string, returnName string, file string, db *sql.DB) e log.Println(err.Error()) } - // TODO - here we need to store the c.NumFmt string value in a new field - insertStmt, err := db.Prepare("insert into return_data (dml_id, ret_id, filename, value, numfmt) values(?,?,?,?,?)") + insertStmt, err := db.Prepare("insert into return_data (dml_id, ret_id, filename, value, numfmt, vFormatted) values(?,?,?,?,?,?)") if err != nil { log.Fatal(err) } defer insertStmt.Close() - _, err = insertStmt.Exec(dmlID, retID, filename, cellData.Value, cellData.NumFmt) + fValue, err := cellData.FormattedValue() + if err != nil { + return err + } + + _, err = insertStmt.Exec(dmlID, retID, filename, cellData.Value, cellData.NumFmt, fValue) if err != nil { log.Fatal(err) } |