Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 9th, 2006, 09:45 AM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default excel

i have a few excel sheets , how can i view them in my app.

or import them in a database

  #2 (permalink)  
Old July 18th, 2013, 08:05 AM
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: excel

Hi, to me the easiest way would be to export Excel to DataGridView like this:
Code:
' Load Excel (XLSX) from a file.
Dim workbook = ExcelFile.Load("Workbook.xlsx")

' Export active worksheet to DataGridView.
DataGridViewConverter.ExportToDataGridView(
    workbook.Worksheets.ActiveWorksheet,
    dataGridView,
    New ExportToDataGridViewOptions() With {.ColumnHeaders = True})
Also here is how to import Excel sheets to a DataSet, every sheet is a new DataTable:
Code:
Dim dataSet = New DataSet()

' Load Excel file.
Dim workbook = ExcelFile.Load("Workbook.xls")

' Export all worksheets to DataSet.
For Each worksheet In workbook.Worksheets
    ' Extract the data from the worksheet to newly created DataTable starting at 
    ' first row and first column for 10 rows or until the first empty row appears.
    Dim dataTable = worksheet.CreateDataTable(New CreateDataTableOptions() With
        {
            .StartRow = 0,
            .StartColumn = 0,
            .NumberOfRows = 10,
            .ExtractDataOptions = ExtractDataOptions.StopAtFirstEmptyRow
        })
    dataTable.TableName = worksheet.Name

    ' Add DataTable to DataSet.
    dataSet.Tables.Add(dataTable)
Next


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in opening excel file in MS Excel 2000 kallol Visual C++ 0 November 16th, 2007 05:48 AM
ASP to Excel - excel output formatting issue mat41 Classic ASP Professional 0 August 13th, 2006 06:41 AM
write multi-sheet Excel w/o Excel.Application manmoth Classic ASP Components 2 November 22nd, 2005 10:56 AM
Excel in win 2000 to excel winxp (excel 2002) Max Excel VBA 3 August 28th, 2003 04:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.