How to set EXCEL cell value programmatically from Visual Studio C++ .NET (Managed Code)

H

Howard Weiss

I would like to set a particular cell in an Excel Spreadsheet to a specific
value

Visual Basic Equivalent would be

Cells(row, column) = x

where row and column locate the cell and x is the value

In C++, I can execute code such as

Excel::Range* range1 = worksheet->get_Range(S"G1", Missing:Value);

to obtain a range object which points ot G1 (row 1, column 7). However, I
cannot find an equivalent to access G1 by its row and column

I have tried get_Range(S"r1c7", Missing:Value) but this does not work.

worksheet->get_Cells() returns a range but does not take any parameters.

Any suggestuions?

Howard Weiss
 
H

Howard Weiss

The following works

Excel::Range* range1 = worksheet->get_Range(S"G1", Missing::Value);
Excel::Range* rangex = range1->get_Resize(S"5", S"5");
Excel::Range* rangey = rangex->get_Offset(S"2", S"2");

It is not obvios that get_Resize and get_Offset have the desired function

Howard
 

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