WorkBookWrap InitWorkWrap(string file) { var wb = new WorkBookWrap() { book = Util.GetWorkBook(file), file = file, filename = System.IO.Path.GetFileName(file) }; wb.sheetCombo = new List <ComboBoxItem>(); var list = new List <SheetNameCombo>(); for (int i = 0; i < wb.book.NumberOfSheets; ++i) { list.Add(new SheetNameCombo() { Name = wb.book.GetSheetName(i), ID = i }); } list.Sort((a, b) => { return(a.Name.CompareTo(b.Name)); }); wb.sheetNameCombos = list; wb.ItemID2ComboIdx = new Dictionary <int, int>(); list.ForEach((a) => { var item = new ComboBoxItem(); item.Content = a; wb.sheetCombo.Add(item); }); for (int i = 0; i < list.Count; ++i) { wb.ItemID2ComboIdx[list[i].ID] = i; } wb.SheetValideRow = new Dictionary <string, int>(); wb.SheetValideColumn = new Dictionary <string, int>(); return(wb); }
// load进来单个文件的情况 public void OnFileLoaded(string file, string tag, FileOpenType type, int sheet = 0) { file = file.Replace("\\", "/"); foreach (var reg in config.NoHeadPaths) { if (System.Text.RegularExpressions.Regex.Match(file, reg).Length > 0) { ProcessHeader.IsChecked = false; } } var wb = Util.GetWorkBook(file); books[tag] = new WorkBookWrap() { book = wb, sheet = sheet, file = file, filename = System.IO.Path.GetFileName(file) }; if (type == FileOpenType.Drag) { if (tag == "src") { SrcFile = file; } else { DstFile = file; } UpdateSVNRevision(file, tag); } if (tag == "src") { SrcFilePath.Content = file; List <ComboBoxItem> list = new List <ComboBoxItem>(); SrcFileSheetsCombo.Items.Clear(); for (int i = 0; i < wb.NumberOfSheets; ++i) { var item = new ComboBoxItem(); item.Content = new SheetNameCombo() { Name = wb.GetSheetName(i), ID = i }; SrcFileSheetsCombo.Items.Add(item); list.Add(item); } SrcFileSheetsCombo.SelectedItem = list[0]; } else if (tag == "dst") { DstFilePath.Content = file; List <ComboBoxItem> list = new List <ComboBoxItem>(); DstFileSheetsCombo.Items.Clear(); for (int i = 0; i < wb.NumberOfSheets; ++i) { var item = new ComboBoxItem(); item.Content = new SheetNameCombo() { Name = wb.GetSheetName(i), ID = i }; DstFileSheetsCombo.Items.Add(item); list.Add(item); } DstFileSheetsCombo.SelectedItem = list[0]; } }