public void AddFile(IList <string> files2) { IList <PrintFileModel> fileNameCustoms = new List <PrintFileModel>(); if (!Utils.CheckListExists(files2)) { return; } for (int a = 0; a < files2.Count; a++) { PrintFileModel fileNameCustom = new PrintFileModel(files2[a]); fileNameCustoms.Add(fileNameCustom); } addFilePagerPage.AddObject(fileNameCustoms); }
/// <summary> /// 手动添加文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddFile_Click(object sender, RoutedEventArgs e) { IList <string> paths = FileUtils.SelectFiles("", "可以多选文件"); if (MyUtils.Utils.CheckListExists(paths)) { IList <PrintFileModel> fs = new List <PrintFileModel>(); foreach (string path in paths) { if (MyUtils.Utils.CheckFileExists(path)) { PrintFileModel fileNameCustom = new PrintFileModel(path); fs.Add(fileNameCustom); } } addFilePagerPage.AddObject(fs); } }
private static IList <PrintFileModel> SheetToList(string path) { IWorkbook workbook = null; //FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); if (path.IndexOf(".xlsx") > 0) // 2007版本 { workbook = new XSSFWorkbook(fileStream); //xlsx数据读入workbook } else if (path.IndexOf(".xls") > 0) // 2003版本 { workbook = new HSSFWorkbook(fileStream); //xls数据读入workbook } fileStream.Close(); if (workbook.NumberOfSheets == 0) { return(null); } IList <PrintFileModel> list = new List <PrintFileModel>(); ICell icell; String key; foreach (IRow irow in workbook.GetSheetAt(0)) { icell = irow.GetCell(0); if (icell == null) { continue; } icell.SetCellType(CellType.String); key = icell.StringCellValue; if (key.Equals("")) { continue; } PrintFileModel fileNameCustom = new PrintFileModel(key); icell = irow.GetCell(1); icell.SetCellType(CellType.String); key = icell.StringCellValue; int count; if (int.TryParse(key, out count)) { fileNameCustom.PrintCount = count; } icell = irow.GetCell(2); icell.SetCellType(CellType.String); key = icell.StringCellValue; bool isTwoPage;//双面打印 if (bool.TryParse(key, out isTwoPage)) { fileNameCustom.IsTwoPage = isTwoPage; } list.Add(fileNameCustom); } return(list); }