//xls和xlsx测试 public void ExcelControllerVersionTest() { ExcelDataController EDC = new ExcelDataController(); List<DealListEntity> DLEL; Assert.AreEqual(OPENEXCEL_ERROR.FORMAT_ERROR, EDC.Open(Environment.CurrentDirectory + "//TestExcel//股票数据.xlsx", out DLEL)); Assert.AreEqual(OPENEXCEL_ERROR.FORMAT_ERROR, EDC.Open(Environment.CurrentDirectory + "//TestExcel//股票数据.xls", out DLEL)); }
//读取数据测试 public void ExcelControllerDataTest() { ExcelDataController EDC = new ExcelDataController(); List<DealListEntity> DLEL; EDC.Open(Environment.CurrentDirectory + "//TestExcel//股票数据.xlsx", out DLEL); Assert.AreNotEqual(0, DLEL.Count); Assert.AreEqual("伊利股份", DLEL[0].name); Assert.AreEqual("600887", DLEL[0].id); }
private List<DealListEntity> OpenExcel(string str) { ExcelDataController edc = new ExcelDataController(); List<DealListEntity> DLEL; Adapter.ErrorAdapter.Show(edc.Open(str, out DLEL)); return DLEL; }
private void OpenExcle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "选择文件"; openFileDialog.Filter = "xls,xlsx文件|*.xls;*.xlsx"; openFileDialog.FileName = string.Empty; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; openFileDialog.DefaultExt = "xls"; if (openFileDialog.ShowDialog() == true) { ExcelDataController edc = new ExcelDataController(); OpenDelegate od = new OpenDelegate(OpenExcel); loading.Visibility = Visibility.Visible; IAsyncResult asyncResult = od.BeginInvoke(openFileDialog.FileName, OpenExcelCompleted, od); //List<DealListEntity> DLEL = od.EndInvoke(asyncResult); //loading.Visibility = Visibility.Collapsed; //DBSyncController.Handler().DealListAdd(DLEL); //DBDataThreadController.DBDataThreadControllerHandler(DBSyncController.Handler()).DealListAdd(DLEL); //StockStateBoxController.Handler().StockBoxInit(); } else { return; } }