读取Excel数据时出现问题 [英] Problem reading the excel data

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

问题描述

我需要从Excel导入数据. Excel的一列中的数据仅包含字母数字和数字.但是只能读取数字单元格值.我的意思是在db's表字段中仅输入空值.指导我修复它.我正在使用VS2005,C#和SQL Server2000.

解决方案

1)首先读取excel文件
2)foreach值在列中检查此值是否为数字

您可以使用以下内容:

 公共  bool  isNumeric(字符串 val,System.Globalization.NumberStyles NumberStyle)
{
    双重结果;
    返回  Double .TryParse(val,NumberStyle,
System.Globalization.CultureInfo.CurrentCulture,输出结果);
} 



3)之后,您可以根据值是否为数字来处理该值

I need to import data from the excel. Data in one column of my excel contains both the alphanumeric and numeric only. But numeric only cell value can''t be read. I mean only null value is entered in the db''s table field. Guide me to fix it. I''m using VS2005 , C# , SQL server 2000.

解决方案

1) Start by reading the excel file
2) foreach value in the column check if this value is numeric

you could use something like this:

public bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle)
{
    Double result;
    return Double.TryParse(val,NumberStyle,
		System.Globalization.CultureInfo.CurrentCulture,out result);
}



3)afterwards you can process the value depending on if it''s numeric or not


这篇关于读取Excel数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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