Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Thu Nov 01, 2018 12:02 pm

Hi,

i'm assigning a cell value based on another cell value by calculating with formula as below in c# programming
sheet3.Range["K3"].Formula = "=VALUE(RIGHT(K6,LEN(K6)-FIND('-',K6)))"

but unfortunately getting an exception like "Attempted to divide by zero." , i'm unable to trace this, please give me a solution to fix this formula.

nb_nelluri
 
Posts: 4
Joined: Thu Nov 01, 2018 11:51 am

Fri Nov 02, 2018 3:15 am

Hi,

Thanks for your inquiry.
Note if there is double quote in your formula, you need to use escape character "\" when setting formula string. Please change your code as below:
Code: Select all
sheet3.Range["K3"].Formula = "=VALUE(RIGHT(K6,LEN(K6)-FIND(\"-\",K6)))";

And after testing the formula with the latest Spire.XLS Pack(Hotfix) Version:8.10.7, everything worked fine. Please try to use this version. If you still have the issue, please share your input Excel and full code for testing.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Tue Nov 06, 2018 6:13 am

Hi,

Greetings from E-iceblue.
Did the code help you solve your issue? Could you please give us some feedback at your convenience?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS