Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

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: 3099
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: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS