Stuck in getting number type(format) cell value from a xls file in Go program. The file has name(text),Due_amount(number) columns in it. I am using the github.com/extrame/xls package.
My code is :
if sheet1 := xlFile.GetSheet(0); sheet1 != nil {
col1 := sheet1.Rows[0].Cols[0]
col2 := sheet1.Rows[0].Cols[0]
for i := 0; i <= (int(sheet1.MaxRow)); i++ {
row1 := sheet1.Rows[uint16(i)]
col1 = row1.Cols[0]
col2 = row1.Cols[1]
fmt.Print("
", col1.String(xlFile), ",", col2.String(xlFile))
}
}
}
The col2.String(xlFile) gives wrong values because column 2 has number type entries.
My xls file contents are :
COL1 | COL2
ADAM | 69057
JHON | 4926
BILL | 22792
Running my program on this gives values like :
[ADAM],[2089.01]
[JHON],[1913.06]
[BILL],[1962.05]
how can i get a number value ? Can some one tell me how to overcome this?
I believe excel handles cell values differently if they are numeric.
The documentation is sparse, but maybe try converting the value to a *NumberCol
like so:
row1.Cols[1].(*xls.NumberCol)