public override void Load(string filename) { Debug.WriteLine("Loading " + filename); CsvDocument csvDoc = new CsvDocument(filename); FileStream fileStream = null; try { //Console.WriteLine("Loading " + filename); fileStream = File.OpenRead(filename); CsvReader reader = new CsvReader(fileStream); string[][] records = reader.ReadAll(); csvDoc.Rows = records; } finally { if (fileStream != null) { fileStream.Close(); } } document = csvDoc; base.Load(filename); }
public override void Save(string filename) { //FileInfo info = new FileInfo( filename ); Debug.WriteLine("Saving " + filename); FileStream outStream = null; try { outStream = File.OpenWrite(filename); outStream.SetLength(0L); CsvWriter writer = new CsvWriter(outStream); //writer.QuoteLimit = -1; CsvDocument csvDoc = this.CsvDocument; writer.WriteAll(csvDoc.Rows); outStream.Flush(); } finally { if (outStream != null) { outStream.Close(); } } base.Save(filename); }
public override void NewDocument() { document = new CsvDocument(); ((CsvDocument)document).Rows = new string[0][]; base.NewDocument(); }
public override void Load( string filename ) { Debug.WriteLine( "Loading " + filename ); CsvDocument csvDoc = new CsvDocument(filename); FileStream fileStream = null; try { //Console.WriteLine("Loading " + filename); fileStream = File.OpenRead( filename ); CsvReader reader = new CsvReader( fileStream ); string[][] records = reader.ReadAll(); csvDoc.Rows = records; } finally { if( fileStream != null ) { fileStream.Close(); } } document = csvDoc; base.Load( filename ); }
public override void DocumentChanged() { // Clear the list. this.listView.Items.Clear(); this.listView.Columns.Clear(); if (manager.Opened) { // Update main form heading. this.Text = Application.ProductName + " - " + manager.Document.Name; CsvDocument doc = (CsvDocument)manager.Document; ListViewItem[] lvItems = new ListViewItem[doc.Rows.Length]; int counter = 0; int maxColumns = 1; foreach (string[] row in doc.Rows) { var lvItem = new ListViewItem(row); lvItems[counter] = lvItem; counter++; if (row.Length > maxColumns) { maxColumns = row.Length; } } for (int col = 0; col < maxColumns; col++) { this.listView.Columns.Add(columnName(col)); } listView.BeginUpdate(); listView.Items.AddRange(lvItems); listView.EndUpdate(); } else { // Update main form heading. this.Text = Application.ProductName; } // Force a display update. //this.Refresh(); }
public override void NewDocument() { document = new CsvDocument(); base.NewDocument(); }