Jump to content

excel a base de dados


André Parreira
 Share

Recommended Posts

Boas

Tenho que criar o excel como base de dados( assim foi pedido)

Tenho este codigo

 Inherits System.Windows.Forms.Form

    Private da As OleDbDataAdapter
    Private dt As DataTable
    Dim conexao_Excel As String = "Provider=Microsoft.Jet.OleDb.4.0;" _
                                & "data source=C:\Users\utilizador\Favorites\Desktop\testar.xls;" _
                                & "Extended Properties=Excel 8.0;"

Que trabalha perfeitamente, mas como é que eu fasso para ele ir buscar a DIR a textbox que tenho introduzida no form???

Obrigado

Link to comment
Share on other sites

depois de aberto o dialog e de o user escolher o ficheiro

Dim openFileDialog1 As System.Windows.Forms.OpenFileDialog

        openFileDialog1 = New System.Windows.Forms.OpenFileDialog()

        If openFileDialog1.ShowDialog() = DialogResult.OK Then
            textBox1.Text = openFileDialog1.FileName
        End If

There are two ways to write error-free programs; only the third one works.

Link to comment
Share on other sites

Sim, e para para fazer a chamada a uma folha excel.

para aparece na datagrid o que vem no excel, eu consigo fazer a chamada apenas a 1 ficheiro excel, mas so eu que escolho, e isso n pode ser

 Inherits System.Windows.Forms.Form
    Private da As OleDbDataAdapter
    Private dt As DataTable
    Dim conexao_Excel As String = "Provider=Microsoft.Jet.OleDb.4.0;" _
                                & "data source=C:\Users\utilizador\Favorites\Desktop\nadanada.xls;" _
                                & "Extended Properties=Excel 8.0;"

meti onde tava a dir uma textbox, mas n deu o erro foi:

An error occurred creating the form. See Exception.InnerException for details.  The error is: A referência de objecto não foi definida como uma instância de um objecto.

Nao estou a ver como resolver isto

Obrigado

Link to comment
Share on other sites

        Dim FileSource As String = "C:\teste.xls"

        Dim workbook As SpreadsheetGear.IWorkbook = SpreadsheetGear.Factory.GetWorkbook(FileSource)

   

        Dim dataSet As DataSet = workbook.GetDataSet("Ordem", SpreadsheetGear.Data.GetDataFlags.FormattedText)

        DataGrid1.DataSource = dataSet

        DataGrid1.DataBind()

There are two ways to write error-free programs; only the third one works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.