当前位置: 首页>>代码示例>>Golang>>正文


Golang Cell.SetInt方法代码示例

本文整理汇总了Golang中github.com/tealeg/xlsx.Cell.SetInt方法的典型用法代码示例。如果您正苦于以下问题:Golang Cell.SetInt方法的具体用法?Golang Cell.SetInt怎么用?Golang Cell.SetInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tealeg/xlsx.Cell的用法示例。


在下文中一共展示了Cell.SetInt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:linchanlau,项目名称:Golang-1,代码行数:60,代码来源:script.go

示例2: createSheet1

func createSheet1(sheet *xlsx.Sheet) {
	r := helpcase.GetAllHelpcase()

	var row *xlsx.Row
	var cell *xlsx.Cell

	row = sheet.AddRow()
	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 = "累計(元)"
	cell = row.AddCell()
	cell.Value = "捐款明細"

	font := &xlsx.Font{Color: "blue", Underline: true}
	style := xlsx.NewStyle()
	style.Font = *font

	for _, helpcase := range r {
		row = sheet.AddRow()
		cell = row.AddCell()
		cell.Value = helpcase.SerialNo
		cell = row.AddCell()
		cell.Value = helpcase.Title
		cell = row.AddCell()
		cell.Value = helpcase.Date
		cell = row.AddCell()
		cell.SetFormula("weekday(\"" + helpcase.Date + "\",2)")
		cell = row.AddCell()
		cell.Value = helpcase.Status
		cell = row.AddCell()
		cell.SetInt(helpcase.Amount)
		cell.NumFmt = "#,##0 ;(#,##0)"
		cell = row.AddCell()
		cell.SetStyle(style)
		cell.SetFormula("HYPERLINK(\"http://search.appledaily.com.tw/charity/projdetail/proj/" + helpcase.SerialNo + "\",\"明細\")")
	}
}
开发者ID:man9527,项目名称:apple_parser,代码行数:46,代码来源:hello.go

示例3: createSheet2

func createSheet2(sheet *xlsx.Sheet) {
	r := helpcase.GetAllHelpcaseDetail()

	var row *xlsx.Row
	var cell *xlsx.Cell

	row = sheet.AddRow()
	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 = "段落數"
	cell = row.AddCell()
	cell.Value = "報導字數"
	cell = row.AddCell()
	cell.Value = "報導內圖片數"
	cell = row.AddCell()
	cell.Value = "報導URL"
	cell = row.AddCell()
	cell.Value = "報導內容全部"

	for _, helpcase := range r {
		row = sheet.AddRow()
		cell = row.AddCell()
		cell.Value = helpcase.SerialNo
		cell = row.AddCell()
		cell.Value = helpcase.Title
		cell = row.AddCell()
		cell.Value = helpcase.Date
		cell = row.AddCell()
		cell.SetFormula("weekday(\"" + helpcase.Date + "\",2)")
		cell = row.AddCell()
		cell.SetInt(helpcase.LikeCount)
		cell = row.AddCell()
		cell.SetInt(helpcase.ParagraphCount)
		cell = row.AddCell()
		cell.SetInt(helpcase.WordCount)
		cell = row.AddCell()
		cell.SetInt(helpcase.ImgCount)
		cell = row.AddCell()
		cell.SetFormula("HYPERLINK(\"" + helpcase.DetailUrl + "\",\"" + helpcase.DetailUrl + "\")")
		cell = row.AddCell()
		cell.Value = helpcase.Content
	}
}
开发者ID:man9527,项目名称:apple_parser,代码行数:52,代码来源:hello.go

示例4: writesheet

func writesheet(project *lair.Project, outfile string) {
	header := []string{
		"#",
		"Title",
		"CVSS",
		"Rating",
		"Description",
		"Evidence",
		"Solution",
		"CVEs",
		"References",
		"Host",
		"Hostname(s)",
		"Port",
		"Service Note",
		"Issue Note(s)",
	}

	var file *xlsx.File
	var sheet *xlsx.Sheet
	var row *xlsx.Row
	var cell *xlsx.Cell

	file = xlsx.NewFile()
	sheet, err := file.AddSheet(project.Name)
	if err != nil {
		log.Printf(err.Error())
	}
	row = sheet.AddRow()
	for _, h := range header {
		cell = row.AddCell()
		cell.Value = h
	}

	for count, issue := range project.Issues {
		var issuenote string
		for _, note := range issue.Notes {
			issuenote += note.Title
			issuenote += note.Content + "\n"
		}
		for _, host := range issue.Hosts {
			var refs []string
			for _, ref := range issue.References {
				refs = append(refs, ref.Link)
			}

			row = sheet.AddRow()
			cell = row.AddCell()
			cell.SetInt(count + 1)
			cell = row.AddCell()
			cell.Value = issue.Title
			cell = row.AddCell()
			cell.SetFloat(issue.CVSS)
			cell = row.AddCell()
			cell.Value = issue.Rating
			cell = row.AddCell()
			cell.Value = issue.Description
			cell = row.AddCell()
			cell.Value = issue.Evidence
			cell = row.AddCell()
			cell.Value = issue.Solution
			cell = row.AddCell()
			cell.Value = strings.Join(issue.CVEs, "\n")
			cell = row.AddCell()
			cell.Value = strings.Join(refs, "\n")
			cell = row.AddCell()
			cell.Value = host.IPv4
			cell = row.AddCell()
			cell.Value = gethostname(host.IPv4, &project.Hosts)
			cell = row.AddCell()
			cell.SetInt(host.Port)
			cell = row.AddCell()
			cell.Value = getcomment(&project.Hosts, issue.Title, host.IPv4, host.Port)
			cell = row.AddCell()
			cell.Value = issuenote
		}
	}
	err = file.Save(outfile)
	if err != nil {
		log.Fatal("Fatal: Unable to write file")
	}
}
开发者ID:lair-framework,项目名称:drone-issues-xlsx,代码行数:82,代码来源:main.go

示例5: createDonation

func createDonation() {
	var currentYear = 0
	var currentMonth = 0

	r := helpcase.GetAllHelpcase()

	var file *xlsx.File
	var sheet1 *xlsx.Sheet
	log.Println("donation export begin")

	for _, hp := range r {

		dt := helpcase.GetAllDonationDetail(hp.SerialNo)

		if len(dt) == 0 {
			continue
		}

		test, _ := time.Parse("2006/1/2", hp.Date)

		var isCurrent = isCurrentYearMonthMatch(currentYear, currentMonth, test.Year(), int(test.Month()))

		if !isCurrent {

			if file != nil {
				var err error
				if currentMonth < 10 {
					err = file.Save(outfolder + "/donation_" + strconv.Itoa(currentYear) + "0" + strconv.Itoa(currentMonth) + ".xlsx")
				} else {
					err = file.Save(outfolder + "/donation_" + strconv.Itoa(currentYear) + strconv.Itoa(currentMonth) + ".xlsx")
				}
				if err != nil {
					fmt.Printf(err.Error())
				}
			}

			file = xlsx.NewFile()

			currentYear = test.Year()
			currentMonth = int(test.Month())
		}

		sheet1 = file.AddSheet(hp.SerialNo)

		var publishDate, _ = time.Parse("2006/1/2", hp.Date)

		var cell *xlsx.Cell
		var row *xlsx.Row
		addHeader(sheet1)
		for _, donator := range dt {
			row = sheet1.AddRow()
			cell = row.AddCell()
			cell.SetString(donator.SerialNo)
			cell = row.AddCell()
			cell.Value = donator.Name
			cell = row.AddCell()
			cell.SetInt(donator.Amount)
			cell.NumFmt = "#,##0 ;(#,##0)"
			cell = row.AddCell()
			cell.Value = donator.Date
			cell = row.AddCell()
			cell.SetFormula("weekday(\"" + donator.Date + "\",2)")

			var dDate, _ = time.Parse("2006/1/2", donator.Date)
			duration := dDate.Sub(publishDate)
			cell = row.AddCell()
			cell.Value = strconv.Itoa(int(duration.Hours() / 24))
			cell = row.AddCell()
			if donator.LongFour == 1 {
				cell.Value = "YES"
			} else {
				cell.Value = "NO"
			}
		}

		row = sheet1.AddRow()
		row.AddCell()
		row = sheet1.AddRow()
		cell = row.AddCell()
		cell.Value = "捐款頁面的URL"
		cell = row.AddCell()
		cell.SetFormula("HYPERLINK(\"http://search.appledaily.com.tw/charity/projdetail/proj/" + hp.SerialNo + "\",\"http://search.appledaily.com.tw/charity/projdetail/proj/" + hp.SerialNo + "\")")

		row = sheet1.AddRow()
		cell = row.AddCell()
		cell.Value = "出刊日期"
		cell = row.AddCell()
		cell.Value = hp.Date
		cell = row.AddCell()
		cell.Value = "專案狀況"
		cell = row.AddCell()
		cell.Value = hp.Status
		row = sheet1.AddRow()
		cell = row.AddCell()
		cell.Value = "捐款總計"
		cell = row.AddCell()
		cell.SetInt(hp.Amount)
		cell.NumFmt = "#,##0 ;(#,##0)"
		cell = row.AddCell()
		cell.Value = "捐款筆數"
//.........这里部分代码省略.........
开发者ID:man9527,项目名称:apple_parser,代码行数:101,代码来源:hello.go


注:本文中的github.com/tealeg/xlsx.Cell.SetInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。