Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

  • 0 odgovora
  • 3.860 pregleda
C# .XLS to DataTable 20.09.2006. u 15:43 · pre 244 meseca #1
Pozz.
Imam problema s jedim Excelom.
ima puno redova. Pa bi bio bezvezan dio da ih prepisujem u nei .MDB ili XML ili tako nesto.
Vec se mucim 2 tjedna s Export Exlel to dataTable koj bi mogao pretrazivat te ispisat odredjen red.

Evo kako sam postavio

Code:

    BindingSource CPL= new BindingSource();

        private void excel_test()
        {

             string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ExcelBase.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
            DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
            DbDataAdapter adapter = factory.CreateDataAdapter();

            DbCommand selectCommand = factory.CreateCommand();
            selectCommand.CommandText = "SELECT IME,PREZIME,BROJ,ULICA FROM [BASE$]";
            DbConnection connection = factory.CreateConnection();
            connection.ConnectionString = connectionString;
            selectCommand.Connection = connection;

            adapter.SelectCommand = selectCommand;

            DataSet cities = new DataSet();
            adapter.Fill(cities);

            CPL.DataSource = cities.Tables[0].DefaultView; ;

            DataGridView PrinterLu = new DataGridView();
            PrinterLu.DataSource = CPL;
            CPL.Filter = "IP like '%10.75.8.202%'";
                             //ERROR koj nije bitan  MessageBox.Show(cities.Tables["BROJ"].Select("9999999").ToString());
        }


Uglavnom. Trebao bi iscitat i protrazit Sheet te ispisat taj ROW al po Tabelama.
Potpis
xxxrugby: "We are all philosophers, when question is about politics!"
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme