string FileFullPath = "d:\\test.mdb";
string strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + FileFullPath + ";Extended Properties='Excel 12.0; HDR=NO; IMEX=1'";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataSet myDataSet = new DataSet();
OleDbDataAdapter odda = new OleDbDataAdapter(string.Format("SELECT * FROM [Sheet1$]", "Sheet1"), conn); //("select * from [Sheet1$]", conn);
odda.Fill(myDataSet, "Sheet1");
try
{
if (myDataSet != null)
{
if (myDataSet.table[0].Rows.Count > 0)
{
//清空目录
DeleteDir(currentPath);
foreach (DataRow dr in myDataSet.table[0].Rows)
{
if (dr[2] != null)
{
//生成图片
Bitmap image = Create_ImgCode(dr[2].ToString(), 17);
//保存图片
SaveImg(currentPath, image);
// SaveImg(currentPath,System.Drawing.Imaging.ImageFormat.Bmp);
}
else
MessageBox.Show("表中无信息");
}
//打开文件夹
Open_File(currentPath);
myDataSet = null;
return;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
CHENCY19820202 发布了4 篇原创文章 · 获赞 1 · 访问量 1852 私信 关注