Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Identifying non-returning formula (blank Cell) | Excel Worksheet Functions | |||
Help Identifying code statement | Excel Discussion (Misc queries) | |||
Identifying first non blank cell in 3 different columns | Excel Discussion (Misc queries) | |||
Personally Identifying information in Excel Sheet | Excel Worksheet Functions | |||
Identifying blank rows | Excel Programming |