使用oledb更新Excel文件的特定单元格 [英] Update specific cell of excel file using oledb

查看:202
本文介绍了使用oledb更新Excel文件的特定单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用oledb更新excel文件的特定单元格.说I7单元,由于某种原因总是I1正在更新.谁能告诉我这段代码有什么问题吗?

I want to update the specific cell of the excel file using oledb. Say I7 cell, for some reason always I1 is getting updated. Can anyone tell me what's wrong with this code?

OleDbConnection oledbConn = new OleDbConnection(connString);
oledbConn.Open();

// I want to set the value of I7 cell to 22, for some reason value is I1 is getting updated :(
OleDbCommand cmd = new OleDbCommand("UPDATE [" + sheetName + "$I7:I7] SET F1=22", oledbConn);
int result = cmd.ExecuteNonQuery();
Console.WriteLine(result);
oledbConn.Close();

推荐答案

我在excel 2007上运行了相同的程序,它运行顺利.对于excel 2013,它不起作用.好像是Excel 2013中的错误.

I ran the same program on excel 2007, it worked smoothly. For excel 2013 it does not work. Seems like a bug in excel 2013.

这篇关于使用oledb更新Excel文件的特定单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆