Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open excel on client machine 2

Status
Not open for further replies.

smbrown

Programmer
Mar 30, 2009
15
US
We are building an application that does some calcs based on values from Oracle queries. Half way through the development I was told I need to retrieve a value from an Excel spreadsheet, instead of having the user select the value from a dropdown. Excel is not installed on the server, and never will be. So I need to get the value client side. Is this even possible?

Any help???
Thanks, SMBrown
 
Yes it is and you have a couple of options.

First, you need to work out where this excel file will be located. If it's already on the server, then that's ok. If not, you will have to get the user to upload it to your site and save it on the server.

Then, you can either:

1. Query the excel file using an OLEDB connection.
2. Add the interop excel libraries and open the excel file using the Excel object library (this may need a license, I'm not sure).

Mark,

Website Design Darlington
Experts, Information, Ideas & Knowledge
ASP.NET Tips & Tricks
 
Would it be easier to just export the data we need from the excel file to a table in Oracle, and then just query the data? I have never needed to do this before (get or export from excel). Just trying to gather my options.

Thanks,
SMBrown

Thanks,
SMBrown
 
this depends. I take the position that a database is just a container like another other storage (xml, web service, xls).
So I would create an object to access the excel worksheet and extract the value. I would have another object to access the database. finally I would have an object, which is a facade, which would get both the data from excel and the database and compute the result. sample below:
Code:
interface IValueExtractor
{
    int extract_value_from(string excel_file);
}

interface IDataRepository
{
    IEnumerable<Entity> get_data();
}

interface IDataCrucher
{
    IEnumerable<Type Of Result> cruch_data_against(string excel_file);
}

class DataCrucher : IDataCrucher
{
    private readonly IValueExtractor extractor;
    private readonly IDataRepository repository;

    public DataCrucher(IValueExtractor extractor, IDataRepository repository)
    {
    }

    public IEnumerable<Type Of Result> cruch_data_against(string excel_file)
    {
        var value = extractor.extract_value_from(excel_file);
        var entities = repository.get_data();
        foreach(var entity in entities)
        {
            yield return entity.do_something_with(value);
        }
    }
}
if this application does most/all of the processing at the database then it may be a better choice to import the data into the database and create a proc to calculate the results.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top