下面的代码是读取某一文件夹下的所有Excel文件,为什么加载不成功呢?
- FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
- folderBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyComputer;
- folderBrowserDialog.ShowNewFolderButton = false;
- if (folderBrowserDialog.ShowDialog(this) == DialogResult.OK)
- {
- this.fpShowExcel.Reset();
- this.fpShowExcel.Sheets.Clear();
- DirectoryInfo directoryInfo = new DirectoryInfo(folderBrowserDialog.SelectedPath);
- foreach (FileInfo item in directoryInfo.GetFiles("*.xls")) // 不区分大小写,即可识别类似.XLS的文件,同时支持.xlsx
- {
- FarPoint.Win.Spread.SheetView sheetView = new FarPoint.Win.Spread.SheetView();
- sheetView.SheetName = item.Name;
- bool success = sheetView.OpenExcel(item.FullName, item.Name);
- this.fpShowExcel.Sheets.Add(sheetView);
- }
- }
复制代码 |
|