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());
}
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!"