PC Review


Reply
Thread Tools Rate Thread

Excel and OleDbDataAdapter. How can i ignore blank columns

 
 
Rollasoc
Guest
Posts: n/a
 
      25th Apr 2008
Hi,

I have an application, that needs to import excel spreadsheets into a
SQL Server
database.


I am using an OleDBDataAdapter to load (fill) the data into a
Dataset.

This works fine, when the spreadsheet is formatted correctly.


Occasionally, person sending us the file, will put the data starting
in column B, not column A. This fails our checks on column count.

They also have started in the third row, which messes up the column
headings. I Get F1 -F6 for the
column headers and only three of the six actual column heading are
read in (as data). The other three
column headings are read in as blanks.

Also occasionally, an extra blank column after the data gets read
in. Well it looks blank in the spreasheet, but I'm assuming they have
done something to it.

Is there an easy way for me to get the DataAdapter to ignore blank
columns and rows?

At the moment, I'm (in my opinion) quite rightly rejecting the file,
but I would like my application to
be more fault tolerant and intellegent.

Rollasoc
 
Reply With Quote
 
 
 
 
mario@gemboxsoftware.com
Guest
Posts: n/a
 
      29th Apr 2008
Hi,

Well maybe OleDB is not the right way to make your application fault
tolerant. Maybe you should try some third party component for reading
Excel files. If you don't need more than 5 sheets and 150 rows per
sheet, then you could use our free component that you can freely use
in commercial apps. Later if you need more then 150 rows or more then
5 sheets, you can easily update to GemBox.Spreadsheet professional.

Mario
GemBox Software
--
GemBox.Spreadsheet for .NET - Easily read and write Excel (XLS, XLSX
or CSV) files
or export to HTML files from your .NET apps. See
http://www.gemboxsoftware.com/GBSpreadsheet.htm
--

On Apr 25, 9:21 am, Rollasoc <rolla...@hotmail.com> wrote:
> Hi,
>
> I have an application, that needs to import excel spreadsheets into a
> SQL Server
> database.
>
> I am using an OleDBDataAdapter to load (fill) the data into a
> Dataset.
>
> This works fine, when the spreadsheet is formatted correctly.
>
> Occasionally, person sending us the file, will put the data starting
> in column B, not column A. This fails our checks on column count.
>
> They also have started in the third row, which messes up the column
> headings. I Get F1 -F6 for the
> column headers and only three of the six actual column heading are
> read in (as data). The other three
> column headings are read in as blanks.
>
> Also occasionally, an extra blank column after the data gets read
> in. Well it looks blank in the spreasheet, but I'm assuming they have
> done something to it.
>
> Is there an easy way for me to get the DataAdapter to ignore blank
> columns and rows?
>
> At the moment, I'm (in my opinion) quite rightly rejecting the file,
> but I would like my application to
> be more fault tolerant and intellegent.
>
> Rollasoc


 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      29th Apr 2008
On Fri, 25 Apr 2008 00:21:34 -0700 (PDT), Rollasoc <(E-Mail Removed)> wrote:

¤ Hi,
¤
¤ I have an application, that needs to import excel spreadsheets into a
¤ SQL Server
¤ database.
¤
¤
¤ I am using an OleDBDataAdapter to load (fill) the data into a
¤ Dataset.
¤
¤ This works fine, when the spreadsheet is formatted correctly.
¤
¤
¤ Occasionally, person sending us the file, will put the data starting
¤ in column B, not column A. This fails our checks on column count.
¤
¤ They also have started in the third row, which messes up the column
¤ headings. I Get F1 -F6 for the
¤ column headers and only three of the six actual column heading are
¤ read in (as data). The other three
¤ column headings are read in as blanks.
¤
¤ Also occasionally, an extra blank column after the data gets read
¤ in. Well it looks blank in the spreasheet, but I'm assuming they have
¤ done something to it.
¤
¤ Is there an easy way for me to get the DataAdapter to ignore blank
¤ columns and rows?
¤
¤ At the moment, I'm (in my opinion) quite rightly rejecting the file,
¤ but I would like my application to
¤ be more fault tolerant and intellegent.

You can select by an Excel Range but you still have to determine where the data starts and ends,
which can probably be done with an initial SELECT on the Worksheet.

Selecting data by Range:

SELECT * FROM [Sheet1$A3:C100]


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I ignore words when sorting excel columns? =?Utf-8?B?VG9taw==?= Microsoft Excel Worksheet Functions 1 18th Jun 2007 10:31 PM
In Excel data validation what is purpose of ignore blank check bo =?Utf-8?B?Y2hoYXlh?= Microsoft Excel Crashes 1 23rd Feb 2007 12:34 AM
how do I get excel to ignore blank cells in formulas =?Utf-8?B?cmJpZ25hbWk=?= Microsoft Excel Worksheet Functions 1 6th May 2005 04:18 AM
Excel formula / How to ignore blank cells? =?Utf-8?B?Qm9uc2FpMTc1Nw==?= Microsoft Excel Worksheet Functions 8 16th Oct 2004 06:05 AM
Excel Formula / Ignore Blank Cells? cpayne1757 Microsoft Excel Worksheet Functions 5 14th Oct 2004 07:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:11 PM.