日期:2014-05-18 浏览次数:20738 次
using (OleDbConnection OleConn = new OleDbConnection(sConnectionString)) { OleConn.Open(); string sql = "SELECT * FROM [总$] "; OleDbDataAdapter OleDaExcel = new OleDbDataAdapter(sql, OleConn); dtt.TableName = reportName; OleDaExcel.Fill(dtt); OleConn.Close(); OleConn.Dispose(); } datarow[] dr dtt.select("F1>='2011/1/1' AND F1<='2011/1/2'"); DataTable newDt = new DataTable(); Foreach(DataRow dr in drs[]) { newDt.ImportRow(dr); }
------解决方案--------------------
貌似excel中的排序有点小问题,大概是这样的 1,11,12,13,14,15,16,17,18,19,2,20,21,22 他的2会排在19后面20前面,貌似是格式的问题,还要在确认一下
------解决方案--------------------
using (OleDbConnection OleConn = new OleDbConnection(sConnectionString))
{
OleConn.Open();
string sql = "SELECT * FROM [总$] ";
OleDbDataAdapter OleDaExcel = new OleDbDataAdapter(sql, OleConn);
dtt.TableName = reportName;
OleDaExcel.Fill(dtt);
OleConn.Close();
OleConn.Dispose();
}
datarow[] dr dtt.select("F1>='2011/1/1' AND F1<='2011/1/2'");
DataTable newDt = new DataTable();
Foreach(DataRow dr in drs[])
{
newDt.ImportRow(dr);
}
然后把 你的datatable中的时间格式改了不就ok了