EXCEL表里有数值7004277597,即当数据值为数字且长度较长时,就会出现7.00428e+009这样的数值出现在DATAGRID里,请问如何去除,
以下我是我的联接方式:
"Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source="+ Path +";"+"Extended Properties='Excel 8.0;HDR=YES;IMEX=1'"
以下我是我的联接方式:
"Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source="+ Path +";"+"Extended Properties='Excel 8.0;HDR=YES;IMEX=1'"
DataGridTextBoxColumn dgtbc= dataGrid1.TableStyles[0].GridColumnStyles[fieldColIndex] as DataGridTextBoxColumn;
if(dgtbc != null)
dgtbc.Format = "D";
————————————————————————————————————————
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dllAdditional information: Index was out of range. Must be non-negative and less than the size of the collection.
DataGridTextBoxColumn dgtbc= myDataGrid.TableStyles[0].GridColumnStyles[5] as DataGridTextBoxColumn;
if(dgtbc != null)
dgtbc.Format = "D";
我在使用Excel时也遇到了这样的问题,我和楼主不同的是,我的数据在Excel中是文本类型的,比如:0912007006,这样的数据被导入到DataSet中后同样也变成了科学记数法,请问一下愚翁,对于文本类型的数据,能否可以使用dgtbc.Format = "D"; 这样的方法解决吗?
导文本类型的直接调用要导入数据的tostring()方法就可以了。
还有一点要说明,就是这种情况不是每次都发生,绝大多数情况下转换都是成功的,但有时会发生上述情况,但不知道为什么