本文整理汇总了Golang中github.com/tealeg/xlsx.Cell.SetFloatWithFormat方法的典型用法代码示例。如果您正苦于以下问题:Golang Cell.SetFloatWithFormat方法的具体用法?Golang Cell.SetFloatWithFormat怎么用?Golang Cell.SetFloatWithFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tealeg/xlsx.Cell
的用法示例。
在下文中一共展示了Cell.SetFloatWithFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}