本文整理汇总了Golang中github.com/tealeg/xlsx.Cell类的典型用法代码示例。如果您正苦于以下问题:Golang Cell类的具体用法?Golang Cell怎么用?Golang Cell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: writeHeaderRowToSheet
func writeHeaderRowToSheet(columns []string, sheet string) error {
activeSheet, err := getActiveSheet(sheet)
if err != nil {
return err
}
headerFont := xlsx.NewFont(12, "Verdana")
headerFont.Bold = true
headerFont.Underline = true
headerStyle := xlsx.NewStyle()
headerStyle.Font = *headerFont
var cell *xlsx.Cell
row := activeSheet.AddRow()
for _, col := range columns {
cell = row.AddCell()
cell.SetStyle(headerStyle)
cell.Value = strings.ToTitle(strings.Replace(col, "_", " ", -1))
}
return nil
}
示例2: formatterExcel
func (client *TrelloClient) formatterExcel(cards []*TrelloCardSearchResult) (err error) {
var (
file *xlsx.File
sheet *xlsx.Sheet
row *xlsx.Row
cell *xlsx.Cell
)
client.config.QuoteChar = "" // we do not need quoting in excel
file = xlsx.NewFile()
if sheet, err = file.AddSheet("Sheet1"); err != nil {
return
}
for _, card := range cards {
row = sheet.AddRow()
for _, column := range client.buildOutputLine(card) {
cell = row.AddCell()
cell.Value = column
}
}
if err != nil {
fmt.Printf(err.Error())
}
err = file.Write(os.Stdout)
if err != nil {
fmt.Printf(err.Error())
}
return err
}
示例3: main
func main() {
var file *xlsx.File
var sheet *xlsx.Sheet
var row *xlsx.Row
var cell *xlsx.Cell
var err error
var RawNbr int = 4
file = xlsx.NewFile()
sheetName := [2]string{"Big", "Small"}
datafile := [2]string{"../data/moveline/big", "../data/moveline/small"}
for i, v := range sheetName {
sheet = file.AddSheet(v)
// 每列标题
text := [4]string{"ID", "X", "Y", "Angle"}
for i := 0; i < RawNbr; i++ {
if i == 0 {
row = sheet.AddRow()
}
cell = row.AddCell()
cell.Value = text[i]
}
files, _ := ListDir(datafile[i], ".dat")
for j := 0; j < len(files); j++ {
write(files[j], sheet, RawNbr)
}
}
fmt.Println("正在向excel写数据......")
err = file.Save("../outexcel/单条鱼路径.xlsx")
if err != nil {
fmt.Printf(err.Error())
}
}
示例4: main
func main() {
var file *xlsx.File
var sheet *xlsx.Sheet
var row *xlsx.Row
var cell *xlsx.Cell
var err error
var RawNbr int = 6
file = xlsx.NewFile()
sheet = file.AddSheet("Sheet1")
// 每列标题
text := [6]string{"ID", "鱼类型", "出现帧", "脚本ID", "X", "Y"}
for i := 0; i < RawNbr; i++ {
if i == 0 {
row = sheet.AddRow()
}
cell = row.AddCell()
cell.Value = text[i]
}
files, err := ListDir("../data/timeline", ".dat")
for j := 0; j < len(files); j++ {
write(files[j], sheet, 6)
}
err = file.Save("../outexcel/巡游鱼路径.xlsx")
if err != nil {
fmt.Printf(err.Error())
}
}
示例5: write
// 写每一个*.dat数据
func write(infile string, sheet *xlsx.Sheet, rawNbr int) {
fmt.Println("正在处理", infile)
var id int
start := strings.LastIndexAny(infile, "\\")
id, _ = strconv.Atoi(infile[start+1 : len(infile)-4])
fmt.Println(id)
var cell *xlsx.Cell
var row *xlsx.Row
file, err := os.Open(infile)
if err != nil {
fmt.Println("Failed to open the input file ", infile)
return
}
defer file.Close()
br := bufio.NewReader(file)
var indexi int = 0
_, _, _ = br.ReadLine()
for {
line, isPrefix, err1 := br.ReadLine()
if err1 != nil {
if err1 != io.EOF {
err = err1
}
break
}
if isPrefix {
fmt.Println("A too long line, seems unexpected.")
return
}
str := string(line) // Convert []byte to string
if len(str) < 5 {
break
}
split := str[1 : len(str)-1]
array := strings.Split(split, ",")
row = sheet.AddRow()
cell = row.AddCell()
cell.SetInt(id)
indexi = 0
for _, v := range array {
if indexi >= rawNbr-1 {
break
}
indexi = indexi + 1
cell = row.AddCell()
value, _ := strconv.Atoi(v)
cell.SetInt(value)
}
}
return
}
示例6: hasBorder
func hasBorder(c *xlsx.Cell) bool {
if c != nil {
if b := c.GetStyle().Border; !(b == defaultBorder || b == emptyBorder) {
return true
}
}
return false
}
示例7: getData
func getData(c *xlsx.Cell) string {
// fmt.Printf("%s\n", cell.String())
val, err := c.SafeFormattedValue()
if err != nil {
val = c.Value
}
return strings.Replace(val, `\ `, ` `, -1)
}
示例8: writeFooterRowToSheet
func writeFooterRowToSheet(totals []int64, sheet string) error {
activeSheet, err := getActiveSheet(sheet)
if err != nil {
return err
}
footerFont := xlsx.NewFont(12, "Verdana")
footerFont.Bold = true
footerStyle := xlsx.NewStyle()
footerStyle.Font = *footerFont
var cell *xlsx.Cell
row := activeSheet.AddRow()
cell = row.AddCell()
cell.SetStyle(footerStyle)
cell.Value = "Total"
for i := 1; i < len(totals); i++ {
cell = row.AddCell()
cell.SetStyle(footerStyle)
cell.SetFloatWithFormat(float64(totals[i]), "#,##0")
}
activeSheet.AddRow()
activeSheet.AddRow()
return nil
}
示例9: main
func main() {
var file *xlsx.File
var sheet *xlsx.Sheet
var row *xlsx.Row
var cell *xlsx.Cell
var err error
file = xlsx.NewFile()
sheet = file.AddSheet("Sheet1")
row = sheet.AddRow()
cell = row.AddCell()
cell.Value = "I am a cell!"
err = file.Save("d:/Desktop/demo_write.xlsx")
if err != nil {
fmt.Printf(err.Error())
}
}
示例10: test2AddSheet
func test2AddSheet() {
var file *xlsx.File
var sheet *xlsx.Sheet
var row *xlsx.Row
var cell *xlsx.Cell
file, _ = xlsx.OpenFile("MyXLSXFile.xlsx")
sheet = file.AddSheet("addSheet")
row = sheet.AddRow()
cell = row.AddCell()
cell.Value = "addSheet000101"
cell = row.AddCell()
cell.Value = "addSheet中文1"
err := file.Save("MyXLSXFile.xlsx")
if err != nil {
fmt.Printf(err.Error())
}
}
示例11: test2
func test2() {
var file *xlsx.File
var sheet *xlsx.Sheet
var row *xlsx.Row
var cell *xlsx.Cell
var err error
file, _ = xlsx.OpenFile("MyXLSXFile.xlsx")
sheet = file.Sheet["Sheet1"]
row = sheet.AddRow()
cell = row.AddCell()
cell.Value = "000101"
cell = row.AddCell()
cell.Value = "中文1"
err = file.Save("MyXLSXFile1.xlsx")
if err != nil {
fmt.Printf(err.Error())
}
}
示例12: test1
func test1() {
var file *xlsx.File
var sheet *xlsx.Sheet
var row *xlsx.Row
var cell *xlsx.Cell
var err error
file = xlsx.NewFile()
sheet = file.AddSheet("Sheet1")
row = sheet.AddRow()
cell = row.AddCell()
cell.Value = "000101"
cell = row.AddCell()
cell.Value = "中文"
err = file.Save("MyXLSXFile.xlsx")
if err != nil {
fmt.Printf(err.Error())
}
}
示例13: addHeader
func addHeader(sheet *xlsx.Sheet) {
var cell *xlsx.Cell
var row *xlsx.Row
row = sheet.AddRow()
cell = row.AddCell()
cell.SetString("筆數")
cell = row.AddCell()
cell.Value = "捐款人姓名"
cell = row.AddCell()
cell.Value = "累計(元) "
cell = row.AddCell()
cell.Value = "捐款明細 / 捐款日期"
cell = row.AddCell()
cell.Value = "星期"
cell = row.AddCell()
cell.Value = "捐款日期與報導日期間隔差時間"
cell = row.AddCell()
cell.Value = "捐款人姓名> 4個字"
}
示例14: memberFormatterExcel
func (client *TrelloClient) memberFormatterExcel(members []*TrelloMember) (err error) {
var (
file *xlsx.File
sheet *xlsx.Sheet
row *xlsx.Row
cell *xlsx.Cell
)
client.config.QuoteChar = "" // we do not need quoting in excel
file = xlsx.NewFile()
if sheet, err = file.AddSheet("Sheet1"); err != nil {
return
}
header := strings.Split(client.config.SearchResultFields, ",")
row = sheet.AddRow()
for _, column := range header {
cell = row.AddCell()
cell.Value = strings.Title(column)
}
for _, member := range members {
row = sheet.AddRow()
for _, column := range client.buildMemberSlice(member) {
cell = row.AddCell()
cell.Value = column
}
}
if err != nil {
fmt.Printf(err.Error())
}
err = file.Write(os.Stdout)
if err != nil {
fmt.Printf(err.Error())
}
return err
}
示例15: addEmbassyInfo
func addEmbassyInfo(sheet *xlsx.Sheet, value string, continentName string, embassyNameCN string, embassyNameEN string) {
row := sheet.AddRow()
var cellFlag *xlsx.Cell
var cellContinentName *xlsx.Cell
var cellEmbassyNameCN *xlsx.Cell
var cellEmbassyNameEN *xlsx.Cell
var cellValue *xlsx.Cell
cellFlag = row.AddCell()
cellFlag.Value = "A"
cellContinentName = row.AddCell()
cellContinentName.Value = continentName
cellEmbassyNameCN = row.AddCell()
cellEmbassyNameCN.Value = embassyNameCN
cellEmbassyNameEN = row.AddCell()
cellEmbassyNameEN.Value = embassyNameEN
cellValue = row.AddCell()
cellValue.Value = value
}