本文整理汇总了Golang中github.com/tealeg/xlsx.Cell.Value方法的典型用法代码示例。如果您正苦于以下问题:Golang Cell.Value方法的具体用法?Golang Cell.Value怎么用?Golang Cell.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tealeg/xlsx.Cell
的用法示例。
在下文中一共展示了Cell.Value方法的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: 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())
}
}
示例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: 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
}
示例5: 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
}
示例6: 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())
}
}
示例7: 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())
}
}
示例8: 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())
}
}
示例9: 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
}
示例10: writeRowToSheet
func writeRowToSheet(data [][]byte, sheet string, format map[string]string) ([]int, error) {
activeSheet, err := getActiveSheet(sheet)
if err != nil {
return nil, err
}
var cell *xlsx.Cell
counts := make([]int, len(data))
row := activeSheet.AddRow()
for idx, bytes := range data {
cell = row.AddCell()
if num, err := strconv.Atoi(string(bytes)); err == nil {
counts[idx] = num
if val, ok := format[strconv.Itoa(idx)]; ok {
cell.SetFloatWithFormat(float64(num), val)
} else {
cell.SetFloatWithFormat(float64(num), "#,##0")
}
} else {
if bytes == nil {
cell.Value = "Unknown"
} else if empty(string(bytes)) {
cell.Value = "Blank"
} else {
cell.Value = string(bytes)
}
}
}
return counts, nil
}
示例11: addWarningInfo
func addWarningInfo(sheet *xlsx.Sheet, value string, title string, time string, source string, url string) {
row := sheet.AddRow()
var cellTitle *xlsx.Cell
var cellTime *xlsx.Cell
var cellSource *xlsx.Cell
var cellUrl *xlsx.Cell
var cellValue *xlsx.Cell
cellTitle = row.AddCell()
cellTitle.Value = title
cellTime = row.AddCell()
cellTime.Value = time
cellSource = row.AddCell()
cellSource.Value = source
cellUrl = row.AddCell()
cellUrl.Value = url
cellValue = row.AddCell()
cellValue.Value = value
}
示例12: 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
}
示例13: addEmbassyInfoByDetails
func addEmbassyInfoByDetails(sheet *xlsx.Sheet, value string, continentName string, embassyNameCN string, embassyNameEN string) {
row := sheet.AddRow()
var cellFlag *xlsx.Cell
var cellContinentName *xlsx.Cell
var cellCountryName *xlsx.Cell
var cellEmbassyNameCN *xlsx.Cell
var cellEmbassyNameEN *xlsx.Cell
var cellMobile *xlsx.Cell
var cellAddress *xlsx.Cell
var cellAddressalid *xlsx.Cell
var cellValue *xlsx.Cell
cellFlag = row.AddCell()
cellFlag.Value = "B"
cellContinentName = row.AddCell()
cellContinentName.Value = continentName
cellCountryName = row.AddCell()
cellCountryName.Value = ""
cellEmbassyNameCN = row.AddCell()
cellEmbassyNameCN.Value = embassyNameCN
cellEmbassyNameEN = row.AddCell()
cellEmbassyNameEN.Value = embassyNameEN
cellMobile = row.AddCell()
cellMobile.Value = ""
cellAddress = row.AddCell()
cellAddress.Value = ""
cellAddressalid = row.AddCell()
cellAddressalid.Value = ""
cellValue = row.AddCell()
cellValue.Value = value
}
示例14: 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())
}
}
示例15: 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個字"
}