Click here to Skip to main content
14,668,366 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have an excel file that i managed to perform some calculation.It's to know the asset value of bridges in a current year.I have 21 fields in the file.Out of the 21 fields,seven fields are just information about the bridge,the rest are used for the calculation based on various conditions.And i have more than 500 records.

Now i wanted to do the same thing using vb.net if it's possible.
1.Read certain fields and store them in the database.(Fields holding bridge information).
2.Read the rest of the fields while performing calculation and lastly store them.

Is there an article or resource to refer to that mentions the same idea? Since most of the articles in the web only show that you can just import data from excel to a database.
Posted

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can't store Excel calculations in any meaningful way in the database: certainly you can't "read" a calculation from Excel and "run" it in the database: the two are not in any way compatible.

You can perform calculations on data within SQL, and return teh results with your data:
SELECT A, B,  A + B AS Result FROM MyTable
But you can;t just grab an excel formula and pass it to SQL for evaluation.
   
Comments
Nebilo 24-Jun-14 8:53am
   
No i don't want to read the calculation.I wanted to write the calculation in vb.net and apply that when a record is read.
Rate this:
Please Sign up or sign in to vote.

Solution 2

You may use a ready solution, the free SaveToDB[^] Express add-in, to save calculated values from Microsoft Excel to a database.

Also, using the add-in, you may configure Excel formulas[^] from database views and stored procedures like
SELECT Name, Price, Qty, '=[@Price]*[@Qty]' AS [Sum] FROM ...


If you definitely want to use vb.net, you may get calculated cell values using the Range.Value property.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100