Example #1
0
        System.Data.DataSet IFileConverter.Import(string filename)
        {
            string connectionString = null;

            if (Options.Provider == "Microsoft.ACE.OLEDB.12.0")
            {
                connectionString = ConnectionStringManager.MakeExcel2007(filename, Options.Username, Options.Password, Options.UseHeader, true);
            }
            else
            {
                connectionString = ConnectionStringManager.MakeExcel(filename, Options.Username, Options.Password, Options.UseHeader, true);
            }

            //if (OpenTableBy == "POSITION")
            //{
            //    OpenTableByPosition(connectionString);
            //}

            return(Common.OleDbTables(connectionString, Tablename, Options.TableFilter));
        }
        private void UpdateTableList()
        {
            switch (InputDataSource)
            {
            case InputDataSourceType.File:
                if (FileSupportsTables(Filename))
                {
                    switch (GetFileExtension(Filename))
                    {
                    case "MDB":
                        Provider         = DatabaseProvider.OleDb;
                        ConnectionString = ConnectionStringManager.MakeAccess(Filename, null, null, true);
                        break;

                    case "XLS":
                        Provider         = DatabaseProvider.OleDb;
                        ConnectionString = ConnectionStringManager.MakeExcel(Filename, null, null, true, true);
                        break;

                    case "XLSX":
                        Provider         = DatabaseProvider.OleDb;
                        ConnectionString = ConnectionStringManager.MakeExcel2007(Filename, null, null, true, true);
                        break;

                    default:
                        throw new ArgumentException("File extension not supported: " + Filename);
                    }
                    GetTableListing(Provider, ConnectionString);
                }
                break;

            case InputDataSourceType.Database:
                GetTableListing(Provider, ConnectionString);
                break;

            default:
                throw new ArgumentOutOfRangeException("InputDataSource=" + InputDataSource);
            }
        }