1.缺少驱动或升级oledb驱动问题:安装 AccessDatabaseEngine_X64 或AccessDatabaseEngine修改数据链接 Provider=Microsoft.ACE.OLEDB.12.0; data source= ;Extended Properties='Excel 12.0; HDR=YES; IMEX=1'
2.循环修改DataTable并修改对应列中的值,解决默认导出科学计数显示
foreach(DataRow dri in dt.Rows)
{ StringBuilder sb = new StringBuilder("=\""); sb=sb.Append(dri["客户编号"]).Append("\""); dri["客户编号"] = sb; }3.格式化导出时间
CONVERT(varchar(100), shijian, 112) ------------------20160601