hi... i need the code for import excel data to gridview in windows forms application... Plz anyone can tell me that code....
A:
Try the following code:
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim MyConnection As System.Data.OleDb.OleDbConnection
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & ExcelFilePath & "; " & _
"Extended Properties=Excel 8.0")
' Select the data from Sheet1 ([in-house$]) of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [in-house$]", MyConnection)
DS = New System.Data.DataSet
MyCommand.Fill(DS)
Dt = DS.Tables(0)
DataGrid1.DataSource = Dt
HotTester
2010-03-09 10:54:20
A:
This is a 4 step process.
I see it as the following:
- You need to get your file onto the server.
- You need to open the (uploaded?) file.
- You need to read the contents of the file, applying any nessesary data parsing.
- You need to display the results in a gridview.
This is a simple enough process, its just a matter of breaking it down into logical steps.
Mick Walker
2010-03-09 10:54:45
A:
SpreadsheetGear for .NET comes with an Excel compatible Windows Forms spreadsheet control which supports displaying / editing Excel workbooks and charts with formulas / calculations / formatting intact.
You can learn about the SpreadsheetGear Windows Forms spreadsheet control here and download the free trial here if you want to try it yourself.
Disclaimer: I own SpreadsheetGear LLC
Joe Erickson
2010-03-09 15:46:05