不使用标题名称更新XLS文件 [英] Update XLS file without using header names

查看:78
本文介绍了不使用标题名称更新XLS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有datagridview,我正在加载我的XLS文件。


然后我就完成了它我使用的是:


cmd.CommandText =" UPDATE [File $ A1:J3000] SET COLUMN_WITH_VALUE ='VALUE'WHERE COLUMN_WITH_CODE = VALUE_FOR_CODE;

cmd.ExecuteNonQuery();



当我有列标题时它工作正常......


但我也有一些没有列名的文件。只是数据。所以我的问题是,如果第一列的值满足某些条件,我可以更新让我们说第三列。

解决方案

我很久以前就像这样处理了Excel,所以我的记忆力并不是那么正确,但它有"Hdr = No"。其中的选项。


但是,使用不带标题的Excel有点危险。它会删除你的信息并将其作为标题(你丢失了第一行)或者它添加了一些难以理解的措辞,如"F1","F2"......作为标题,这样你的文件中就会有不必要的信息。


这只是来自我的记忆,一些好人会告诉你更好的解决方案。祝你好运¥




$





Hello all,

I have datagridview, where I am loading my XLS file.

Then I just run through it and I am using something like:

cmd.CommandText = "UPDATE [File$A1:J3000] SET COLUMN_WITH_VALUE = 'VALUE' WHERE COLUMN_WITH_CODE = VALUE_FOR_CODE;
cmd.ExecuteNonQuery();

It works fine when I have column headers...

But I also have some files without column names. Just data. So my question is how I can update let's say third column if value at first column meet some criteria.

解决方案

i handled Excel like this long time ago, so my memory is not so correct though, it has "Hdr=No" options within it.

But, using Excel without header is somewhat dangerous. It cut out your information and make it as header (you lose the first line) OR it adds some stuid wordings like "F1", "F2".. as heading so you have needless information in your file.

this is only from my memory, some nice guy will tell you the better solution. Good Luck






这篇关于不使用标题名称更新XLS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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