OWC Range get and set value c#

W

williams.marty

I am just trying to get and set values in a Range using C#. I cannot
get this to work.

Anyone have code samples or suggestions, I cannot find documentation
using C#.

Name name = wb.Names["myrange",Missing.Value,Missing.Value];
rngData = name.RefersToRange;

//does not work
object s = (object) rngData[1,6];

How can I get the value of cell [1,6] and set the value of a cell.
Thanks in advance.
 
A

Alvin Bruney [MVP]

The following is from my upcoming book, it shows how to set values


Code-listing 4.22 Sample in-memory spreadsheet load




C# snippet




//load the spreadsheet with data

axSpreadsheet1.ActiveCell.get_Range("A1","B1").Value2 = "1";

axSpreadsheet1.ActiveCell.get_Range("A2","B2").Value2 = "2";

axSpreadsheet1.ActiveCell.get_Range("A3","B3").Value2 = "3";

axSpreadsheet1.ActiveCell.get_Range("A4","B4").Value2 = "4";

axSpreadsheet1.ActiveCell.get_Range("A5","B5").Value2 = "5";

//bind the spreadsheet to the chart control

axChartSpace1.DataSource = (msdatasrc.DataSource)(object)axSpreadsheet1;




VB.NET snippet




'load the spreadsheet with data

axSpreadsheet1.ActiveCell.get_Range("A1","B1").Value2 = "1"

axSpreadsheet1.ActiveCell.get_Range("A2","B2").Value2 = "2"

axSpreadsheet1.ActiveCell.get_Range("A3","B3").Value2 = "3"

axSpreadsheet1.ActiveCell.get_Range("A4","B4").Value2 = "4"

axSpreadsheet1.ActiveCell.get_Range("A5","B5").Value2 = "5"

'bind the spreadsheet to the chart control

axChartSpace1.DataSource = CType(CType(axSpreadsheet1,
msdatasrc.DataSource,Object))


hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top