在wince 上对excel 文件的支持比较少,读比较麻烦,可以把excel 文件另存为csv文件,csv文件可以改后缀变成txt文件。
  读txt的时候用 string.splite 分隔之下面是我自己写的只读的类
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Reflection;
namespace demo_rfcom_wince
{
class csvFile
{
private  StreamReader m_StreamReader;
private string[] m_StrArry;
private int m_FileLinesCount = 0;
public csvFile(string name)
{
string cvsFileName;
cvsFileName  =  System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName)+"\"+name;
m_StreamReader = new StreamReader(cvsFileName, Encoding.Default);
while(m_StreamReader.ReadLine()!=null)m_FileLinesCount++;
m_StrArry = new string[m_FileLinesCount+1];
//load
int i;
m_StreamReader.BaseStream.Position = 0;
for (i = 0; i < m_FileLinesCount; i++)m_StrArry[i] = m_StreamReader.ReadLine();
}
~csvFile()
{
m_StreamReader.Close();
}
public int GetLinesCount()
{
return m_FileLinesCount;
}
public string Read(int x, int y)
{
if (y > m_FileLinesCount) return null;
string[] r = new string[128];
r = m_StrArry[y].Split(',');
return r[x];
}
}
}