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

  • SEARCH
  • Home
  • 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 8628439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:32:39+00:00 2026-06-12T08:32:39+00:00

im building an excel upload feature on my web. it will read excel data

  • 0

im building an excel upload feature on my web. it will read excel data using OLEDB. the problem is the excel file that user inputted can be either in ‘real’ excel file or excel in html import extended properties so the connection string is different. right now i handle it with try catch. if the first conn string generate exception then it will open connection with the other connection string in catch.

the problem is my lead says i can’t use that kinda method. so is there any way so i can do that without try catch ( anything related throwing an exception ), or to see whether the excel file is in excel 8.0 extended properties or html import extended properties.

try
{
    ...
    try
    {
        connection.ConnectionString = GetConnectionString(pathCopy);
        connection.Open();
    }
    catch
    {
        connection.ConnectionString = GetConnectionStringHTMLEncoded(pathCopy);
        connection.Open();
    }
    ...
catch (Exception ex)
{
    ...
}

Thanks

  • 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-12T08:32:41+00:00Added an answer on June 12, 2026 at 8:32 am

    You can verify the internal makeup of the file by opening one of the html string encoded files in a text editor (like notepad). You should see that the underlying file is still html text. You should be able to read the first line of the file and check for the string “html”

    var reader = System.IO.File.OpenText(pathCopy);
    string firstLine = reader.ReadLine();
    if (firstLine.IndexOf("html", StringComparison.InvariantCultureIgnoreCase) > 0)
        //some stuff
    else
        //other stuff
    

    You shouldn’t get an error on the binary file, you’ll just get some really strange characters in the string—fortunately, characters that won’t include the string “html”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a console app that moves data into an excel file (using EPPlus
I'm building an app that pulls data in from an excel .csv file and
I'm building an iPhone app that has to download an Excel (.xls) file from
I am building an application in Excel which will enable a user to select
I am building a web application that shows stock data trends and stock quotes.
I'm building a C# application using .NET 3.5 that will require logging in to
I am building an Excel add-in that sends the active workbook as an attachment
I'm building a c/c++ program and I'm using MS Excel for results representation. The
building a site using PHP and MySQL that needs to store a lot of
I have a web application that allows users to upload certain documents relevant to

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.