Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:19:03+00:00 2026-06-08T05:19:03+00:00

thanks for reading, my doubt is the following, im trying to get data from

  • 0

thanks for reading, my doubt is the following, im trying to get data from an xls file but it has to be done locally, without uploading the file, i have done something similiar with txts files and works perfectly :

Function Send(ByVal file As HttpPostedFileBase) As ActionResult
    Dim line As String
    Dim textreader As System.IO.StreamReader = New StreamReader(file.InputStream)
    While Not textreader.EndOfStream
        line = textreader.ReadLine()
        ViewBag.line = line
    End While
    Return View("Index")
End Function

but i cant do the same to the excel file, first of all, because i cant use the streamreader, so when using this code i dont know how to specify the dir of my xls file

    Dim oApp As Excel.Application = New Excel.Application
    Dim oWB As Excel.Workbook
    Dim oSheet As Excel.Worksheet
    oWB = oApp.Workbooks.Open(file.inputstream)  <-- HERE IS WHERE I GET (AN OBVIOUS) ERROR

does anybody knows how to open the file locally? thanks for reading 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:19:05+00:00Added an answer on June 8, 2026 at 5:19 am

    There are several ways of doing it, one of them is accessing the file “database style”
    …

    ...
        string filePath = string.Format("C:\\TEST\\{0}.xlsx", Guid.NewGuid().ToString());
        var fileStream = File.Create(filePath);
        input.CopyTo(file.InputStream);
        fileStream.Close();
    
        string cn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath  + ";Extended Properties=\"Excel 12.0;HDR=YES;\"";
        string query = "SELECT * FROM SHEET_NAME";
    
        conn= new OleDbConnection(cn);
        conn.Open();
        OleDbCommand woOleCommand = new OleDbCommand(query, conn);
    
        DbDataReader result = woOleCommand.ExecuteReader();
    
        // Read the DataReader...
    ...
    

    So basically you query Sheets like tables, if they are indeed tables, this code might be what you’re looking for.

    On the other hand, if you still need to use automation, try something like this instead:

    ...    
    object missing = System.Reflection.Missing.Value;
    wBook = (Excel._Workbook)xl.Workbooks.Open(filePath, false, false, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); 
    ...
    

    Reading InputStream

    using (var fileStream = File.Create(filePath)) {
         file.InputStream.CopyTo(fileStream); 
    } 
    // Now you got your stream on a file (filePath) so you can work with it.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for reading. I have done a search, read multiple posts (lost count) and
Firs of all thanks for reading this. I'm having trouble updating the progress from
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
Thanks for reading. I'm trying to put a label and an image on a
Hi and thanks for reading this. I am trying to use the IF EXISTS/IF
Thanks for reading. I'm trying to use CoreImage in iOS 5 to alter the
I am newbie to EJB's. From all the reading and searching I have done
Thanks for reading this. I am dynamically generating some data which includes a select
Thanks for reading! var data = <html><head><title>Hello</title></head><body>Hello Body</body></html>; I want to print data including
Thanks for reading. I'm a bit new to jQuery, and am trying to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.