Exemplo n.º 1
0
        /// <summary>
        /// Imports data (and optionally metadata) into the document.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="data">The data, which may just be <paramref name="table"/>.Rows.</param>
        public void ImportData(DataTable table, IEnumerable <DataRow> data)
        {
            if (this.IsAuthoringDictionary)
            {
                // First import schema
                this.Variables.ImportSchema(table);
                this.CommitDictionary();
            }

            System.Collections.IEnumerable dataRows = data;
            if (dataRows == null)
            {
                dataRows = table.Rows;
            }

            foreach (DataRow row in dataRows)
            {
                SpssCase caseRow = this.Cases.New();
                for (int col = 0; col < table.Columns.Count; col++)
                {
                    caseRow.SetDBValue(this.Variables.GenerateColumnName(table.Columns[col].ColumnName), row[col]);
                }

                caseRow.Commit();
            }
        }