Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The GetCellFormula in same cell not working properly #844

Closed
raochq opened this issue May 19, 2021 · 0 comments
Closed

The GetCellFormula in same cell not working properly #844

raochq opened this issue May 19, 2021 · 0 comments

Comments

@raochq
Copy link
Contributor

raochq commented May 19, 2021

when I copy a sheet to another file. The formula in same cell may not correct.

package main

import (
	"github.com/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
	sheetName := "Sheet1"
	f1, _ := excelize.OpenFile("input.xlsx")
	f2 := excelize.NewFile()
	rows, _ := f1.GetRows(sheetName)
	for r, row := range rows {
		for c, s := range row {
			axis, _ := excelize.CoordinatesToCellName(c+1, r+1)
			formula, _ := f1.GetCellFormula(sheetName, axis)
			if formula != "" {
				f2.SetCellFormula(sheetName, axis, formula)
			} else {
				f2.SetCellValue(sheetName, axis, s)
			}
		}
	}
	f2.SaveAs("output.xlsx")
}

input.xlsx

raochq added a commit to raochq/excelize that referenced this issue May 19, 2021
raochq added a commit to raochq/excelize that referenced this issue May 19, 2021
raochq added a commit to raochq/excelize that referenced this issue May 19, 2021
raochq added a commit to raochq/excelize that referenced this issue May 19, 2021
raochq added a commit to raochq/excelize that referenced this issue Jun 7, 2021
@xuri xuri closed this as completed in b02f864 Aug 14, 2021
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant