Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

C# .XLS to DataTable

[es] :: .NET :: .NET Desktop razvoj :: C# .XLS to DataTable

[ Pregleda: 2727 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

xxxrugby

Član broj: 16068
Poruke: 653
*.adsl.net.t-com.hr.

Sajt: www.zagreb-rugby.hr


Profil

icon C# .XLS to DataTable20.09.2006. u 14:43 - pre 214 meseci
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.
xxxrugby: "We are all philosophers, when question is about politics!"
 
Odgovor na temu

[es] :: .NET :: .NET Desktop razvoj :: C# .XLS to DataTable

[ Pregleda: 2727 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.