0

I have an excel sheet with a complex formula applied in it. I want to use this formula from my C# code for some calculations. My scenario is like this User fill a form (web) and submit, our program will fetch these values and applied in the hosted excel sheet and get the result.

is this possible?

Help is highly appreciable.

Thanks,

demo
  • 6,038
  • 19
  • 75
  • 149
vks
  • 6,649
  • 7
  • 36
  • 55
  • 1
    Do you examine https://stackoverflow.com/questions/2049355/c-sharp-evaluate-excel-logical-formulas (this link) – ahmeticat Mar 04 '19 at 13:53

1 Answers1

0

This really should go in the comments section, as I have a few questions to clarify your request. However, as I do not yet have the reputation, my questions must go here.

Is it a formula residing in your existing Excel document that you want to utilize that formula/document without re-writing the code?

Or are you asking if it is possible to write the same formula that you have working on the Excel sheet in c#?

If the former, it is conceivable to pass data into the Excel sheet from the code. After all we can use code to append to other document types, why not an Excel document? And if we can fetch specific lines from other document types, why not from an Excel document (especially since the grid/cell layout provides easier addressable points). However, while it is conceivable, doesn't mean it's easy. It's an interesting proposition, and I'd like to do some experiments on that.

If it is the latter, then depending on the formula's requirements, you may just need to use the appropriate math libraries and write out the formula directly in the c# code. You may not be able to visually see how everything ties together as nicely in the Excel document (with the referenced cells highlighted), but you could modularize components of the formula more easily as sub-functions and re-use values easily enough with variables.

wolfsshield
  • 757
  • 5
  • 14
  • Yes first point I required.Use excel sheet formula from c# code .But the input values are from web form , we need to read it from web and applied to excel sheet and return result to web UI. Thank You for your reply – vks Mar 05 '19 at 05:17