Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Identifying Blank Excel Sheet through .NET code


Hi All,

I am reading an excel sheet using OLEDB connection , now what I want t
know is how can I make out that the sheet whether the sheet is blank o
not ??

Here is my code
////////////////////////////////////////////////////////////////////////////////////

Dim connString As [String] = "Provider=Microsoft.Jet.OLEDB.4.0;"
"Data Source=" + excelFile + ";Extended Properties=Excel 8.0;"

objConn = New OleDb.OleDbConnection(connString)

Dim commandTxt As String = "Select * from [Sheet1$]"

command = New System.Data.OleDb.OleDbDataAdapter(commandTxt, objConn)

objConn.Open()
DS = New DataSet
command.Fill(DS)
////////////////////////////////////////////////////////////////////////////////


I tried this

Dim i as integer
i = DS.Tables(0).Rows.Count

if i 1 then
end if

But the results were not as excepted and did not form any pattern
using which I could conclude that this condition gives me the exac
result


Thanx & Regards,
Abh

--
Abhi Kuma
-----------------------------------------------------------------------
Abhi Kumar's Profile: http://www.msusenet.com/member.php?userid=502
View this thread: http://www.msusenet.com/t-187104747

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Identifying Blank Excel Sheet through .NET code

Normally I use one of these to test for blank sheets. I tested using Sheet3
so, of course, you will need to change that part of the code to whatever you
require.

Hope it helps!

If IsEmpty(Sheet3.UsedRange) Then _
'Do something

OR

If Application.CountA(Sheet3.Cells) = 0 Then _
'Do something

"Abhi Kumar" wrote:


Hi All,

I am reading an excel sheet using OLEDB connection , now what I want to
know is how can I make out that the sheet whether the sheet is blank or
not ??

Here is my code
/////////////////////////////////////////////////////////////////////////////////////

Dim connString As [String] = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelFile + ";Extended Properties=Excel 8.0;"

objConn = New OleDb.OleDbConnection(connString)

Dim commandTxt As String = "Select * from [Sheet1$]"

command = New System.Data.OleDb.OleDbDataAdapter(commandTxt, objConn)

objConn.Open()
DS = New DataSet
command.Fill(DS)
/////////////////////////////////////////////////////////////////////////////////


I tried this

Dim i as integer
i = DS.Tables(0).Rows.Count

if i 1 then
end if

But the results were not as excepted and did not form any pattern ,
using which I could conclude that this condition gives me the exact
result


Thanx & Regards,
Abhi


--
Abhi Kumar
------------------------------------------------------------------------
Abhi Kumar's Profile: http://www.msusenet.com/member.php?userid=5025
View this thread: http://www.msusenet.com/t-1871047471


  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Identifying Blank Excel Sheet through .NET code

One more thought, are you just testing to ensure the cell contents are blank
or can the sheets have shapes/objects embedded in them. If so, you could
also add something similare to the following, but I am unsure if this would
capture all possible shapes/objects, etc (as I don't deal much with embedded
objects).


If Sheet3.Shapes.Count = 0 Then
'Do something


"Abhi Kumar" wrote:


Hi All,

I am reading an excel sheet using OLEDB connection , now what I want to
know is how can I make out that the sheet whether the sheet is blank or
not ??

Here is my code
/////////////////////////////////////////////////////////////////////////////////////

Dim connString As [String] = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelFile + ";Extended Properties=Excel 8.0;"

objConn = New OleDb.OleDbConnection(connString)

Dim commandTxt As String = "Select * from [Sheet1$]"

command = New System.Data.OleDb.OleDbDataAdapter(commandTxt, objConn)

objConn.Open()
DS = New DataSet
command.Fill(DS)
/////////////////////////////////////////////////////////////////////////////////


I tried this

Dim i as integer
i = DS.Tables(0).Rows.Count

if i 1 then
end if

But the results were not as excepted and did not form any pattern ,
using which I could conclude that this condition gives me the exact
result


Thanx & Regards,
Abhi


--
Abhi Kumar
------------------------------------------------------------------------
Abhi Kumar's Profile: http://www.msusenet.com/member.php?userid=5025
View this thread: http://www.msusenet.com/t-1871047471


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Identifying Blank Excel Sheet through .NET code


Hi JMB,

I think to use Sheet.UsedRange or Sheet.Object requires that I have t
create an object of something like

Dim sheet as Excel.Worksheet

If this the case then , my point is that I want to avoid all sorts o
Excel Automation

Else
if I have misunderstood u pls elaborate the sulution a little more.

Regards,
Abh

--
Abhi Kuma
-----------------------------------------------------------------------
Abhi Kumar's Profile: http://www.msusenet.com/member.php?userid=502
View this thread: http://www.msusenet.com/t-187104747

  #5   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Identifying Blank Excel Sheet through .NET code

No, I believe you are correct that it would require using Excel automation.

Sorry it does not help.


"Abhi Kumar" wrote:


Hi JMB,

I think to use Sheet.UsedRange or Sheet.Object requires that I have to
create an object of something like

Dim sheet as Excel.Worksheet

If this the case then , my point is that I want to avoid all sorts of
Excel Automation

Else
if I have misunderstood u pls elaborate the sulution a little more.

Regards,
Abhi


--
Abhi Kumar
------------------------------------------------------------------------
Abhi Kumar's Profile: http://www.msusenet.com/member.php?userid=5025
View this thread: http://www.msusenet.com/t-1871047471


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying non-returning formula (blank Cell) Vibeke Excel Worksheet Functions 9 September 4th 09 09:29 AM
Help Identifying code statement Ayo Excel Discussion (Misc queries) 1 November 29th 07 03:50 AM
Identifying first non blank cell in 3 different columns belvy123 Excel Discussion (Misc queries) 5 February 21st 07 06:36 AM
Personally Identifying information in Excel Sheet Fonz Excel Worksheet Functions 1 June 12th 06 04:34 PM
Identifying blank rows Raj[_8_] Excel Programming 5 February 25th 04 10:59 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"