Question Reading Excel, why do certain rows cause functions to not work?

sherbert99

New member
Joined
Jun 19, 2010
Messages
1
Programming Experience
5-10
Hi I have code that pulls the data from an Excel 2003 worksheet using vb.net.

It works on some worksheets. But for some reason on some worksheets I am having a problem. Cells with functions such as =today() are showing up blank. I did some testing and found if I remove text from a cell above the row with that function, the function then works fine. For example if I put a simple letter "F" in a row 3 rows above my function then my function shows up blank. It works fine in Excel but when pulling it with vb.net it's blank.

Any ideas why this is happening. Is there maybe a better way to pull this data then my method? Below is my code. Thanks


VB.NET:
<%@ Page Language="VB" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Oledb" %>


<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim myDataset As New DataSet()


Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\inetpub\wwwroot\book.xls; Extended Properties=""Excel 8.0;"""


Dim myData As New OledbDataAdapter("SELECT * FROM [sheet1$]", strConn)
myData.TableMappings.Add("Table", "ExcelTest")
myData.Fill(myDataset)

DataGrid1.DataSource = myDataset.Tables(0).DefaultView
DataGrid1.DataBind()
End Sub
</script>

<html>
<head></head>
<body>
<p><asp:Label id=Label1 runat="server">SpreadSheetContents:</asp:Label></p>
<asp:DataGrid id=DataGrid1 runat="server"/>
</body>
</html>
 
Back
Top