public void DownLoad() { var dataTable = new DataTable(); var bussinessTable = new DataTable(); bussinessTable.Columns.AddRange( new DataColumn[] { new DataColumn("city_code"), new DataColumn("geo"), new DataColumn("area_code"), new DataColumn("area_name"), new DataColumn("PATH"), new DataColumn("business_type"), }); dataTable.Columns.AddRange( new DataColumn[] { new DataColumn("area_code"), new DataColumn("area_type"), new DataColumn("X"), new DataColumn("area_name"), new DataColumn("parent_code"), new DataColumn("Y"), }); var chinaRow = dataTable.NewRow(); chinaRow["parent_code"] = 0; chinaRow["area_code"] = 1; chinaRow["area_name"] = "中国"; chinaRow["area_type"] = 0; // chinaRow["geo"] = "116.413554,39.911013"; chinaRow["X"] = 116.413554; chinaRow["Y"] = 39.911013; dataTable.Rows.Add(chinaRow); getSubItem(this.chinaCode, dataTable, bussinessTable); AsposeCellsHelper.ExportToExcel( dataTable, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "行政区.xls")); AsposeCellsHelper.ExportToExcel( bussinessTable, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "商业圈.xls")); }
/// <summary> /// 读取CSV文件 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public static DataTable ReadCsvFile(string filePath) { return(AsposeCellsHelper.ExportToDataTable(filePath, true)); //StreamReader sr = new StreamReader(new FileStream(filePath, FileMode.Open), Encoding.GetEncoding("GB2312")); //String line = sr.ReadLine(); //string[] cloumns = line.Split(','); //DataTable dataTable = new DataTable(); //DataColumn dc = null; //for (int i = 0; i < cloumns.Length; i++) //{ // dc = dataTable.Columns.Add(cloumns[i], Type.GetType("System.String")); //} //while ((line = sr.ReadLine()) != null) //{ // DataRow row = dataTable.NewRow(); // List<string> list = getRowValue(line, cloumns.Length); // row.ItemArray = list.ToArray(); // dataTable.Rows.Add(row); //} //sr.Dispose(); //return dataTable; }