Get- do something formula- and put the result back to the same cell

All I want to do is get a numeric cell value and multiply by .000001, Then put the result back in the same cell and do this for all the row values in column 0.

I tried coding something like the following using VB.NET:

Dim i_format As Integer = 3
For i_format = 3 To cells.GetLastDataRow(0)
Dim freq_cell As Cell = newWorksheet.Cells(i_format, 0)

'How do I match the correct type
Dim freq_x As Integer = freq_cell
newWorksheet.Cells(i_format, 0).PutValue(freq_x)
Next

I tried various ways to convert from a string object to a single or double using things like "cells.ConvertStringToNumericValue(freq_cell)" But everything is a type mismatch.

Can anyone point me in the right direction?

Thanks

After trying several additional attempts I think I found a way to do it:


'Gets the maximum row index of cell which contains data in the specified column.
For i_format = 3 To cells.GetLastDataRow(0)
Dim freq_cell As Single = CSng(newWorksheet.Cells(i_format, 0).Value)
newWorksheet.Cells(i_format, 0).PutValue(freq_cell * 0.000001)
Next

This seems to work - I would be interested to see other ways to produce the same result.

Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

We are pleased to know that you sorted out this issue. If you face any other problem, please feel free to post, we will be glad to help you asap.