在网格视图中绑定excel工作表数据 [英] bind excel sheet data in grid view
本文介绍了在网格视图中绑定excel工作表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我在网格视图中绑定Excel工作表数据并且工作正常,但在excel工作表中有一个日期,就像7 / 27/2013 12:00:00 AM但是在excel表中它是27/07/2013。
我需要一种格式,当日期字段来临时它将以不需要时间的格式显示。
我的bind excel表的代码是: -
OleDbConnection oconn = new OleDbConnection( @ Provider = Microsoft.Jet.OLEDB.4.0; Data Source = + file_name + ;扩展属性= Excel 8.0);
OleDbCommand ocmd = new OleDbCommand( select *来自[申请单$],oconn);
oconn.Open();
OleDbDataReader odr = ocmd.ExecuteReader();
GridView1.DataSource = odr;
GridView1.DataBind();
oconn.Close();
如果有任何解决方案请帮助。
谢谢。 。
解决方案
,oconn);
oconn.Open();
OleDbDataReader odr = ocmd.ExecuteReader();
GridView1.DataSource = odr;
GridView1.DataBind();
oconn.Close();
如果有任何解决方案请帮助。
谢谢..
关于日期,您可以将其传递为Text =''或HeaderText =''
<%#Bind(Failure_date,{0:dd / MM / yyyy})%>
Hello
I am binding Excel sheet data in a grid view and it is working fine, but in excel sheet there is a date, which is coming like 7/27/2013 12:00:00 AM but in excel sheet it is 27/07/2013.
I need it in a format, when date field will come it will show in a format don't need time.
My code for bind excel sheet is :-
OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file_name + ";Extended Properties=Excel 8.0");
OleDbCommand ocmd = new OleDbCommand("select * from [Requisition$]", oconn);
oconn.Open();
OleDbDataReader odr = ocmd.ExecuteReader();
GridView1.DataSource = odr;
GridView1.DataBind();
oconn.Close();
if any solution then please help.
Thanks..
解决方案
", oconn); oconn.Open(); OleDbDataReader odr = ocmd.ExecuteReader(); GridView1.DataSource = odr; GridView1.DataBind(); oconn.Close();
if any solution then please help.
Thanks..
Concerning to date you can pass this as Text='' or HeaderText = ''
<%# Bind("Failure_date", "{0:dd/MM/yyyy}") %>
这篇关于在网格视图中绑定excel工作表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文