static void Main(string[] args) { Console.WriteLine("SPSS file writing demo:"); if (File.Exists("example.sav")) { File.Delete("example.sav"); } CreateExampleDocument(); Console.WriteLine("Exporting a DataTable demo... (the source code is interesting)"); DataTable dt = SpssConvert.ToDataTable(GetFileName()); if (File.Exists("example2.sav")) { File.Delete("example2.sav"); } SpssConvert.ToFile(dt, "example2.sav", MetaDataCallback); Console.WriteLine("SPSS dictionary copying demo:"); if (File.Exists("example3.sav")) { File.Delete("example3.sav"); } using (SpssDataDocument doc = SpssDataDocument.Create("example3.sav", GetFileName())) { PrintMetaData(doc); } Console.WriteLine("Demo concluded. Press any key to end."); Console.ReadKey(); }
public void MetaData() { string SAVfilename; using (System.CodeDom.Compiler.TempFileCollection tfc = new System.CodeDom.Compiler.TempFileCollection()) { SAVfilename = tfc.AddExtension("sav", true); SpssConvert.ToFile(tblTest, tblTest.Select(), SAVfilename, FillInMetaData); Console.WriteLine("The file with metadata is stored at: " + SAVfilename); } }
public void ToFile() { DataTable dt = new DataTable(); dt.Columns.Add("var1", typeof(int)); dt.Columns.Add("var2", typeof(string)); dt.Rows.Add(new object[] { 1, "hi" }); using (TempFileCollection tfc = new TempFileCollection()) { tfc.KeepFiles = false; string filename = tfc.AddExtension("sav"); SpssConvert.ToFile(dt, dt.Select(), filename, null); } }