2015-03-19 10:39:41 +01:00
|
|
|
package xls
|
|
|
|
|
2016-09-30 05:46:51 +02:00
|
|
|
type rowInfo struct {
|
2015-03-19 10:39:41 +01:00
|
|
|
Index uint16
|
2018-04-05 15:28:01 +02:00
|
|
|
First uint16
|
|
|
|
Last uint16
|
2015-03-19 10:39:41 +01:00
|
|
|
Height uint16
|
|
|
|
Notused uint16
|
|
|
|
Notused2 uint16
|
|
|
|
Flags uint32
|
|
|
|
}
|
|
|
|
|
2017-02-21 09:27:01 +01:00
|
|
|
//Row the data of one row
|
2015-03-19 10:39:41 +01:00
|
|
|
type Row struct {
|
2017-02-21 09:27:01 +01:00
|
|
|
wb *WorkBook
|
2016-09-30 05:46:51 +02:00
|
|
|
info *rowInfo
|
2017-02-21 09:27:01 +01:00
|
|
|
cols map[uint16]contentHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
//Col Get the Nth Col from the Row, if has not, return nil.
|
|
|
|
//Suggest use Has function to test it.
|
|
|
|
func (r *Row) Col(i int) string {
|
2018-04-05 15:28:01 +02:00
|
|
|
var val string
|
|
|
|
var serial = uint16(i)
|
|
|
|
|
2017-02-21 09:27:01 +01:00
|
|
|
if ch, ok := r.cols[serial]; ok {
|
2018-04-05 15:28:01 +02:00
|
|
|
val = ch.String(r.wb)[0]
|
2017-02-21 09:27:01 +01:00
|
|
|
} else {
|
|
|
|
for _, v := range r.cols {
|
|
|
|
if v.FirstCol() <= serial && v.LastCol() >= serial {
|
2018-04-05 15:28:01 +02:00
|
|
|
val = v.String(r.wb)[serial-v.FirstCol()]
|
|
|
|
|
|
|
|
break
|
2017-02-21 09:27:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-05 15:28:01 +02:00
|
|
|
return val
|
2017-02-21 09:27:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//FirstCol Get the number of First Col of the Row.
|
|
|
|
func (r *Row) FirstCol() int {
|
2018-04-05 15:28:01 +02:00
|
|
|
return int(r.info.First)
|
|
|
|
}
|
|
|
|
|
|
|
|
//LastCol Get the number of Last Col of the Row.
|
|
|
|
func (r *Row) LastCol() int {
|
|
|
|
return int(r.info.Last)
|
2015-03-19 10:39:41 +01:00
|
|
|
}
|