André Parreira Posted March 12, 2009 at 04:46 PM Report #250313 Posted March 12, 2009 at 04:46 PM Boas Com ajuda, ja consegui fazer o datagrid ir buscar o ficheiro excel que quer. mas agora ele as vezes da erro. Aqui: Dim da As New OleDbDataAdapter("SELECT * FROM [Folha1$]", conexao_Excel) Diz que a folha1 nao esta declarada( ou e sheet1 ou plan1) mas como fasso para meter os 3?? outra duvida, para gravar depois de ter alterado, meti este codigo. Dim excel As Object excel = CreateObject("excel.Application") excel.Application.Workbooks.Add(True) excel.Save(textbox.text) ele cria, em vez de criar, vou ver a folha e esta toda em branko. Agradecia ajuda dscp o incomodo Obrigado
Hellblazer Posted March 12, 2009 at 04:54 PM Report #250315 Posted March 12, 2009 at 04:54 PM Dim excel As Object excel = CreateObject("excel.Application") excel.Application.Workbooks.Add(True) excel.Save(textbox.text) Entao ele ali esta a criar um novo ficheiro de excel e grava... nao tens de preencher o ficheiro? There are two ways to write error-free programs; only the third one works.
André Parreira Posted March 12, 2009 at 06:00 PM Author Report #250338 Posted March 12, 2009 at 06:00 PM Boas desde ja agradeço a ajuda 🙂 sim, tenho ke ir buscar um ficheiro excel( ja konseguido) depois se kiser alterar alguma coisa, haja 1 botao para gravar. Como haverei de meter? Dim excel As Object excel = CreateObject("excel.Application") excel.Application.Workbooks.open(textbox.text) excel.Save(textbox.text) e sobre esta duvida. Dim da As New OleDbDataAdapter("SELECT * FROM [Folha1$]", conexao_Excel) como posso resolver?? Obrigado pela ajuda
j.mendes24 Posted March 13, 2009 at 11:59 AM Report #250490 Posted March 13, 2009 at 11:59 AM Testei aqui no meu o open e tb nao da, ele apaga o outro, é como cria-se um novo, tu tens que fazer, para o que esta no datagrid, gravar numa folha de excel, pelo ke presebi. Em relaçao a outra duvida, nao te consigo ajudar.. Bom resto de trabalho
André Parreira Posted March 13, 2009 at 01:40 PM Author Report #250516 Posted March 13, 2009 at 01:40 PM Pois nao estou mm a ver komo é ke é Agradecia Ajuda Obrigado
Hellblazer Posted March 13, 2009 at 02:36 PM Report #250531 Posted March 13, 2009 at 02:36 PM entao mas pera tu ja nao estas a ir buscar a informaçao a um ficheiro excel? esplica la detalhadamente o que queres There are two ways to write error-free programs; only the third one works.
André Parreira Posted March 13, 2009 at 02:48 PM Author Report #250532 Posted March 13, 2009 at 02:48 PM Boas Sim ja consigo, aparecer no datagrid o conteúdo do excel, mas agora queria que quando eu fizesse alguma alteração, haja um botão para gravar as alterações na mesma folha excel( ou outra isso depois o utilizador escolhe) Ja criei o botão, já consigo gravar este o codigo que meti 'Dim myStream As Stream 'Dim saveFileDialog1 As New SaveFileDialog() 'saveFileDialog1.FileName = "Introduza o Nome" 'saveFileDialog1.Filter = " Excel 2003 (*.xls) |*.xls" 'saveFileDialog1.FilterIndex = 2 'saveFileDialog1.RestoreDirectory = True 'If saveFileDialog1.ShowDialog() = DialogResult.OK Then ' myStream = saveFileDialog1.OpenFile() ' If (myStream IsNot Nothing) Then ' myStream.Close() ' MsgBox(saveFileDialog1.FileName, MsgBoxStyle.Information, "Bem Sucedido") ' End If 'End If mas quando vou depois ver a folha excel, ela esta em branco, como tivesse criado uma folha nova. Espero ter sido esclarecedor Obrigado pela ajuda
Hellblazer Posted March 13, 2009 at 04:47 PM Report #250569 Posted March 13, 2009 at 04:47 PM E mostra la o codigo do butao de gravar There are two ways to write error-free programs; only the third one works.
André Parreira Posted March 13, 2009 at 08:28 PM Author Report #250603 Posted March 13, 2009 at 08:28 PM O botao para gravar e esse ai em cima Obrigado pla ajuda
André Parreira Posted March 14, 2009 at 02:58 PM Author Report #250667 Posted March 14, 2009 at 02:58 PM Boas pessoal( sei ke nao devia dar um "up" mas tal é o desespero) ja me fartei de prokurar, de testar, mas nao consigo fazer com que o botão guarde o conteúdo da datagrid numa folha excel. Agradecia a ajuda. Obrigado
José Lopes Posted March 14, 2009 at 05:00 PM Report #250690 Posted March 14, 2009 at 05:00 PM posta ai o exemplo algures Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!
André Parreira Posted March 14, 2009 at 06:20 PM Author Report #250697 Posted March 14, 2009 at 06:20 PM dos que vi, estes 2 foram os melhores, mas mm assim n konsegui meter. Dim appExcel As New Excel.Application Dim worExcel As Excel.Workbook Dim sheExcel As Excel.Worksheet worExcel = appExcel.Workbooks.Add sheExcel = appExcel.Sheets(1) sheExcel.Name = "Faturas.xls" Dim strString As String strString = "OLEDB;Provider=SQLOLEDB.1;Password=;Persist Security Info=True; User ID=sa;Initial Catalog=;Data Source= " With sheExcel.QueryTables.Add(Connection:=strString, Destination:=sheExcel.Range("A1")) .CommandType = Excel.XlCmdType.xlCmdSql .CommandText = "Procedure SQL" .Name = "+New SQL Server Connection" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = Excel.XlCellInsertionMode.xlInsertDeleteCells .SavePassword = False .SaveData = False .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh(BackgroundQuery:=False) End With sheExcel.QueryTables(1).Delete() appExcel.Visible = True e este Public Function DataSetToExcel(ByVal dtSource As System.Data.DataSet, ByVal sFileName As String) Dim iRowCount As Integer = dtSource.Tables(0).Rows.Count Dim iColCount As Integer = dtSource.Tables(0).Columns.Count Dim oData(iRowCount, iColCount) As Object Dim iRow As Integer, iCol As Integer For iRow = 0 To iRowCount - 1 For iCol = 0 To iColCount - 1 oData(iRow, iCol) = dtSource.Tables(0).Rows(iRow).Item(iCol) Next Next ' Start Excel and get Application object Dim oExcel As Excel.Application = New Excel.Application() oExcel.Visible = True ' Make visible ' Get a new workbook Dim oBook As Excel._Workbook = CType(oExcel.Workbooks.Add(Missing.Value), Excel._Workbook) Dim oSheet As Excel._Worksheet = CType(oBook.ActiveSheet, Excel._Worksheet) Dim oRange As Excel.Range = oSheet.Range("A1") oRange = oRange.Resize(iRowCount, iColCount) oRange.Value = oData oSheet.SaveAs(sFileName) oExcel.Workbooks.Close() oExcel.Quit() oBook = Nothing oSheet = Nothing oExcel = Nothing End Function End Class Obrigado pela ajuda
José Lopes Posted March 14, 2009 at 06:28 PM Report #250700 Posted March 14, 2009 at 06:28 PM De onde vêm os dados do datagrid? Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!
André Parreira Posted March 14, 2009 at 06:38 PM Author Report #250704 Posted March 14, 2009 at 06:38 PM Vem de uma folha excel
José Lopes Posted March 14, 2009 at 06:41 PM Report #250706 Posted March 14, 2009 at 06:41 PM entao... mas tu queres actualizar essa folha...ou criar numa nova? Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!
André Parreira Posted March 14, 2009 at 06:42 PM Author Report #250707 Posted March 14, 2009 at 06:42 PM actualizar faço o conteúdo dessa folha aparecer na datagrid(ja sei como se faz) depois se kiser alterar alguma coisa ele actualize a folha excel Obrigado pela ajuda
André Parreira Posted March 15, 2009 at 10:48 PM Author Report #250913 Posted March 15, 2009 at 10:48 PM Alguem tem alguma sugestao?? dscp estar a insistir, mas e mm urgente. Obrigado pela ajuda
André Parreira Posted March 16, 2009 at 11:56 AM Author Report #250951 Posted March 16, 2009 at 11:56 AM Ja conseguiii... que alivio 😁 deixo aqui o site onde consegui fazer, se alguem kiser http://translate.google.pt/translate?hl=pt-PT&sl=en&u=http://forums.techarena.in/software-development/1105140.htm&ei=oja-SaBn2bSMB-bazZAI&sa=X&oi=translate&resnum=1&ct=result&prev=/search%3Fq%3Dhttp://forums.techarena.in/software-development/1105140.htm%26hl%3Dpt-PT
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now