由于要做一个地图学的作业,老师要求得写个分析程序,就草略的写了点~哈,效果还不错,就是饼图粗糙了点~下面就是截图:
EXCEL导入DATASET的代码我就写在下面吧,可以帮助一下新手~
public void ExcelToDS(string Path) { string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection myConn = new OleDbConnection(strConn); myConn.Open(); string strCom = "SELECT * FROM [Sheet1$]"; OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn); myDataSet = new DataSet(); myCommand.Fill(myDataSet, "[Sheet1$]"); myConn.Close(); dataGridView1.DataMember = "[Sheet1$]"; dataGridView1.DataSource = myDataSet; }
这里的Sheet1$就是那个Excel里的表一~名字不一样或者需要其他的表就改吧~