杰出pkg.go golang
我正在使用Excelize包装来操纵Excel文件。我对setCellformula func有问题,它不应用公式。我粘贴了一个基本的例子,我只是在尝试
func main() {
f := excelize.NewFile()
f.SetCellValue("Sheet1", "A1", "ID")
f.SetCellValue("Sheet1", "B1", "Nome")
f.SetCellValue("Sheet1", "D1", "Cognome")
f.SetCellValue("Sheet1", "C1", "Email")
f.SetCellValue("Sheet1", "D1", "IDENTITY_CARD_EXPIRE_DATE")
f.SetCellValue("Sheet1", "E1", "TOTAL")
f.SetCellValue("Sheet1", "E2", "1")
f.SetCellValue("Sheet1", "E3", "5")
f.SetCellValue("Sheet1", "E4", "10")
//formula
f.SetCellFormula("Sheet1", "E6", "=SUBTOTALE(9;E2:E8)")
f.SetColWidth("Sheet1", "A", "D", 30)
if err := f.SaveAs("Personal_Data.xlsx"); err != nil {
log.Fatal(err)
}
}
谢谢大家
I'm using the excelize packaging to manipulate excel files. I am having a problem with the setcellformula func, it does not apply the formula. I paste a basic example, where I was just trying
func main() {
f := excelize.NewFile()
f.SetCellValue("Sheet1", "A1", "ID")
f.SetCellValue("Sheet1", "B1", "Nome")
f.SetCellValue("Sheet1", "D1", "Cognome")
f.SetCellValue("Sheet1", "C1", "Email")
f.SetCellValue("Sheet1", "D1", "IDENTITY_CARD_EXPIRE_DATE")
f.SetCellValue("Sheet1", "E1", "TOTAL")
f.SetCellValue("Sheet1", "E2", "1")
f.SetCellValue("Sheet1", "E3", "5")
f.SetCellValue("Sheet1", "E4", "10")
//formula
f.SetCellFormula("Sheet1", "E6", "=SUBTOTALE(9;E2:E8)")
f.SetColWidth("Sheet1", "A", "D", 30)
if err := f.SaveAs("Personal_Data.xlsx"); err != nil {
log.Fatal(err)
}
}
Thank you all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码有三个问题:
首先,将数字值添加为字符串。您应该使用整数作为
第三参数:第二
个参数,在公式中,您不应添加相等的符号,必须使用逗号而不是semicolon,并且必须使用英语函数名称:
此外,您在公式中具有圆形参考,因为它在E6单元格中,但是范围是您的示例中的e2:e8,其中包含e6。因此,您也必须改变它。
You have three problems with your code:
First, you add the numeric values as strings. You should use integers as the
third parameter:
Second, in the formula, you shouldn't add equal sign, you must use comma instead of semicolon and you must use the english function name:
Furthermore you have a circular reference in your formula, because it is in E6 cell, but the range is E2:E8 in you example, which has E6 in it. So you have to change that too.