private void PopulateSheets() { var connectionString = $"Provider=Microsoft.Jet.OLEDB.4.0; data source={FilePath}; Extended Properties=Excel 8.0;"; using (var connection = new OleDbConnection(connectionString)) { connection.Open(); var dataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dataTable == null) { return; } var sheets = new List <string>(); foreach (DataRow row in dataTable.Rows) { sheets.Add(row["TABLE_NAME"].ToString()); } Sheets = sheets; if (Sheets.Any()) { SelectedSheet = Sheets.FirstOrDefault(); } } }
public void CreateProject(object obj) { var dia = DialogCoordinator.Instance; if (ProjectName == null || ProjectName == string.Empty) { dia.ShowMessageAsync(this, "Warnung", "Projekt Name darf nicht leer sein!"); return; } if (File.Exists(Environment.CurrentDirectory + @"\Projects\" + ProjectName)) { dia.ShowMessageAsync(this, "Warnung", "Projekt bereits vorhanden!"); return; } if (Sheets.Any() == false) { dia.ShowMessageAsync(this, "Warnung", "Mindestens ein Eintrag muss vorhanden sein!"); return; } Project proj = new Project(); proj.DisplayText = ProjectName; proj.Filepath = Environment.CurrentDirectory + @"\Projects\" + ProjectName; proj.Sheets = Sheets; _projectDataProvider.Serialize(proj); Messenger.Trigger("LoadWelcomeScreen", null); }
public int GetNextSheetSource() { if (Sheets.Any()) { return(Sheets.Max(z => z.source.Value) + 1); } return(0); }
protected override void SaveRealize(string path) { if (Sheets.Any()) { using var stream = new FileStream(path, FileMode.Create); WorkBook.Write(stream); } }
public override void Save() { if (Sheets.Any(s => s.Value.IsDirty)) { using (FileStream stream = new FileStream(rawFilePath, FileMode.Create, FileAccess.Write)) { rawWorkbook.Write(stream); } foreach (var sheet in Sheets.Values) { sheet.IsDirty = false; } } }
public override void Validate() { if (!Sheets.Any()) { throw new ArgumentException($"정의된 시트 별 옵션이 없습니다. Field: 'sheets'"); } foreach (var kv in Sheets) { foreach (var option in kv.Value) { option.Validate(); } } }
protected override void SaveRealize(string path, bool isSitu) { if (!Sheets.Any()) { return; } if (isSitu) { if (!PackBook.Saved) { PackBook.Save(); } } else { PackBook.SaveAs(path); } }
public int GetNewSheetId() => Sheets.Any() ? Sheets.Max(sheet => sheet.ID) + 1 : 0;