Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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"
Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:03 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.