20
0
xls/cell_range.go

64 lines
1.1 KiB
Go
Raw Permalink Normal View History

2015-03-24 06:06:52 +01:00
package xls
import (
"fmt"
)
2015-09-30 04:40:01 +02:00
// range type of multi rows
2015-03-24 06:06:52 +01:00
type Ranger interface {
FirstRow() uint16
LastRow() uint16
}
2015-09-30 04:40:01 +02:00
// range type of multi cells in multi rows
2015-03-24 06:06:52 +01:00
type CellRange struct {
FirstRowB uint16
LastRowB uint16
FristColB uint16
LastColB uint16
}
func (c *CellRange) FirstRow() uint16 {
return c.FirstRowB
}
func (c *CellRange) LastRow() uint16 {
return c.LastRowB
}
func (c *CellRange) FirstCol() uint16 {
return c.FristColB
}
func (c *CellRange) LastCol() uint16 {
return c.LastColB
}
2015-09-30 04:40:01 +02:00
//hyperlink type's content
2015-03-24 06:06:52 +01:00
type HyperLink struct {
CellRange
2015-03-25 04:03:05 +01:00
Description string
TextMark string
TargetFrame string
Url string
ShortedFilePath string
ExtendedFilePath string
IsUrl bool
2015-03-24 06:06:52 +01:00
}
2015-09-30 04:40:01 +02:00
//get the hyperlink string, use the public variable Url to get the original Url
2015-03-24 06:06:52 +01:00
func (h *HyperLink) String(wb *WorkBook) []string {
res := make([]string, h.LastColB-h.FristColB+1)
2015-03-25 04:03:05 +01:00
var str string
if h.IsUrl {
str = fmt.Sprintf("%s(%s)", h.Description, h.Url)
} else {
str = h.ExtendedFilePath
}
2015-03-24 06:06:52 +01:00
for i := uint16(0); i < h.LastColB-h.FristColB+1; i++ {
res[i] = str
}
return res
}