从Excel将数据导入数据表时出错 [英] Error While import data from excel to datatable

查看:95
本文介绍了从Excel将数据导入数据表时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试将数据从Excel工作表导入到数据表中,以便自动修剪列值中的空格.

IE.如果我有一列像name一样具有值Kap R的列,则在导入时会将数据另存为KAPR.

有人可以帮我吗?

谢谢,

Hi,

I am trying to import data from an excel sheet to a datatable so spaces from column value are automatically trimmed.

ie. If I have one column like name that have value Kap R then at the time of importing it saves data as KAPR.

Can anyone help me out on this?

Thanks,

推荐答案

一个简单的For Each循环遍历条目,如果为=",则丢弃.
还可以根据需要使用.ToUpper来提供大写字母.
A simple For Each loop through the entry, and if =" " then discard.
Also employ a .ToUpper to give the upper case as required.


如Dave所述,您可以使用VBA中的Replace函数删除空格.

As Dave already mentioned you can remove the spaces using the Replace function in VBA.

<pre lang="vb">Replace( old_text, start, number_of_chars, new_text )</pre><br />


这篇关于从Excel将数据导入数据表时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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