Revit.SDK.Samples.RoomSchedule.XlsDBConnector.RetrieveAllTables C# (CSharp) Method

RetrieveAllTables() public method

Get all available table names from .xls data source
public RetrieveAllTables ( ) : List
return List
        public List<String> RetrieveAllTables()
        {
            // clear the old tables list firstly
            m_tables.Clear();

            // get all table names from data source
            DataTable schemaTable = m_objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
                new object[] { null, null, null, "TABLE" });
            for (int i = 0; i < schemaTable.Rows.Count; i++)
            {
                m_tables.Add(schemaTable.Rows[i].ItemArray[2].ToString().TrimEnd('$'));
            }

            return m_tables;
        }

Usage Example

示例#1
0
        /// <summary>
        /// Import room spread sheet and display them in form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void importRoomButton_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog sfdlg = new OpenFileDialog())
            {
                // file dialog initialization
                sfdlg.Title            = "Import Excel File";
                sfdlg.Filter           = "Excel File(*.xls)|*.xls";
                sfdlg.RestoreDirectory = true;
                //
                // initialize the default file name
                int       hashCode    = m_document.GetHashCode();
                SheetInfo xlsAndTable = new SheetInfo(String.Empty, String.Empty);
                if (CrtlApplication.EventReactor.DocMappedSheetInfo(hashCode, ref xlsAndTable))
                {
                    sfdlg.FileName = xlsAndTable.FileName;
                }
                //
                // import the select
                if (DialogResult.OK == sfdlg.ShowDialog())
                {
                    try
                    {
                        // create xls data source connector and retrieve data from it
                        m_dataBaseName = sfdlg.FileName;
                        XlsDBConnector xlsCon = new XlsDBConnector(m_dataBaseName);

                        // bind table data to grid view and ComboBox control
                        tablesComboBox.DataSource = xlsCon.RetrieveAllTables();

                        // close the connection
                        xlsCon.Dispose();
                    }
                    catch (Exception ex)
                    {
                        tablesComboBox.DataSource = null;
                        MyMessageBox(ex.Message, MessageBoxIcon.Warning);
                    }
                }
            }
        }
All Usage Examples Of Revit.SDK.Samples.RoomSchedule.XlsDBConnector::RetrieveAllTables