Read XLSM file via VB.NET and ASP.NET Getting #REF! where data should be

Posted on 2012-08-20
Last Modified: 2012-08-20
I have been able to read a XLSM(Excel) file via and and pass data to a gridvew. That part works the problem I'm having is. Im getting a #REF! where data should be.

The Excel file works great on its own, after enabling macro contact, but I'm unable to get GridView to take in calculated data it just display #REF! instead.

Code I'm using:
     Dim DBConnection = New OleDbConnection( _
  "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("Staffing.xlsm") & ";" & _
  "Extended Properties=""Excel 12.0 Macro;HDR=YES;IMEX=1""")

        Dim SQLString As String = "SELECT * FROM [Staffing$]"
        Dim DBCommand = New OleDbCommand(SQLString, DBConnection)
        Dim DBReader As Data.IDataReader = DBCommand.ExecuteReader()

        gv.DataSource = DBReader


I tried with no imex same problem, screenshot attached
Question by:marcuschang

    Accepted Solution

    Disabling security in spreadsheet solved problem
    Thanks though

    Author Closing Comment

    I'm getting smarter :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
    Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
    The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
    This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now