Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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
 
Old August 27th, 2007, 12:31 PM
Authorized User
 
Join Date: Jun 2003
Location: Lisbon, , Portugal.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Import Excel Range to Dataset

Hello,

I need to import an Excel range (not the whole worksheet...I begam to import the whole sheet, not a good ideia...) to a Dataset. Does any one can help me?

Thanks in advance

Elisa

Elisa Resina
__________________
Elisa Resina
 
Old August 28th, 2007, 01:54 AM
Authorized User
 
Join Date: May 2007
Location: moeskroen, henegauwen, Belgium.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to swifty_programmer
Default

Hi,
You can use a StreamReader to read the file and select what part you want. You have a special StreamReader called FileReader for making it easier.

example:

Code:
if (_ofdSelectFile.ShowDialog() == DialogResult.OK)
            {
                using (StreamReader sr = new StreamReader(_ofdSelectFile.FileName))
                {
                    //Read file with url's
                    while (!sr.EndOfStream)
                    {
                        string directImportLine = sr.ReadLine();
                        //actions with 1 line
                    }
                }
            }


They are also a few tips and tricks with excel sheets.
You can acces (write and read) data from an excel sheet just like in a DB. It uses special SQL statement so you can select cells, colums or rows.

Hope it helped.

Grtz
 
Old August 28th, 2007, 05:39 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Amman, , Jordan.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In such a case I really prefer using oledbCommand, I thing you should try it

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
 
Old August 28th, 2007, 05:52 AM
Authorized User
 
Join Date: Jun 2003
Location: Lisbon, , Portugal.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I already tryed with OleDBCommand (select * from [xxxx]) and it importes the whole sheet. I just want to import a range of values, which I don't know how to do it.

thanks

Elisa

Quote:
quote:Originally posted by zaghmout
 In such a case I really prefer using oledbCommand, I thing you should try it

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
Elisa Resina
 
Old August 28th, 2007, 05:59 AM
Authorized User
 
Join Date: Jun 2003
Location: Lisbon, , Portugal.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

Thank you for your answer. I'm going to read it and try it!

thanks,

Elisa

Quote:
quote:Originally posted by swifty_programmer
 Hi,
You can use a StreamReader to read the file and select what part you want. You have a special StreamReader called FileReader for making it easier.

example:

Code:
if (_ofdSelectFile.ShowDialog() == DialogResult.OK)
            {
                using (StreamReader sr = new StreamReader(_ofdSelectFile.FileName))
                {
                    //Read file with url's
                    while (!sr.EndOfStream)
                    {
                        string directImportLine = sr.ReadLine();
                        //actions with 1 line
                    }
                }
            }


They are also a few tips and tricks with excel sheets.
You can acces (write and read) data from an excel sheet just like in a DB. It uses special SQL statement so you can select cells, colums or rows.

Hope it helped.

Grtz

Elisa Resina




Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing a Range from Excel JezLisle Access VBA 0 July 27th, 2007 02:54 AM
import excel xml Spreadsheet to dataset krissri_mtc XSLT 2 May 30th, 2007 07:21 AM
Method Range - VBA - Excel teatimer Beginning VB 6 0 May 22nd, 2006 03:50 AM
Import dat from cvs or xls file into dataset briisek C# 2 September 9th, 2005 11:05 AM





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