无法读取单元格包含Excel中的“$” [英] Cant Read Cells Contain '$' from Excel
本文介绍了无法读取单元格包含Excel中的“$”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码从excel读取,但有一些单元格{D2,D4}编程。无法从excel文件中读取它们,其中包含('$'){D2,D4}阅读此单元格的任何帮助..
I am Using this code to read from excel but there are some cells{D2 , D4 }the prog . cant read them from the excel file which contain ('$') {D2 , D4} any help to read this cells ..
try
{
OpenFileDialog ex = new OpenFileDialog();
ex.Filter = "XLS|*.xls|All|*.*";
if (ex.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", ex.FileName);
var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet7$]", connectionString);
var ds = new DataSet();
adapter.Fill(ds);
DataTable data = ds.Tables[0];
DATAGRID1.DataSource = data;
}
So how to get this values as shown in the picture
http://postimg.org/image/xeanxst5v/ [ ^ ]
推荐答案
' ){D2,D4}阅读此单元格的任何帮助..
') {D2 , D4} any help to read this cells ..
try
{
OpenFileDialog ex = new OpenFileDialog();
ex.Filter = "XLS|*.xls|All|*.*";
if (ex.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", ex.FileName);
var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet7
,connectionString);
var ds = new DataSet();
adapter.Fill(ds);
DataTable data = ds.Tables [0];
DATAGRID1.DataSource = data;
}
", connectionString); var ds = new DataSet(); adapter.Fill(ds); DataTable data = ds.Tables[0]; DATAGRID1.DataSource = data; }
So how to get this values as shown in the picture
http://postimg.org/image/xeanxst5v/ [ ^ ]
最后我能看到你发布的图片(用文字更好地解释),并理解一些值(带
Finally I was able to see the image you posted (better explain it by words), and understood that some of the values (those with
的那些
这篇关于无法读取单元格包含Excel中的“$”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文