Skip to content

Setting cell's type (format) #1738

Closed Answered by konart
konart asked this question in Q&A
Discussion options

You must be logged in to vote

To answer my own question: this is done via SetCellStyle() method like so:

		cell, err := excelize.JoinCellName(cname, rowNum)
		if err != nil {
			return err
		}

		s, err := file.NewStyle(&excelize.Style{NumFmt: textNumberFormat})
		if err != nil {
			return err
		}

		if err := file.SetCellStyle(sheetName, cell, cell, s); err != nil {
			return err
		}

		if err := file.SetCellValue(sheetName, cell, elements[i]); err != nil {
			return err
		}

https://xuri.me/excelize/en/style.html#number_format

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by konart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant