How to get the value of a merged cell using c#

  • Thread starter Thread starter Issac
  • Start date Start date
I

Issac

Hi,
Is there a standard way to get the value of a merged cell using c#?

I tried both
1) target.Text
and
2) object[,] arr =
(object[,])target.get_Value(XlRangeValueDataType.xlRangeValueDefault);
if (null != arr)
ret = Convert.ToString(arr[1, 1]);

If I used method 1), sometimes I got empty string back even though the
value is not an empty string.
If I used method 2), sometimes I got an exception even though the cell
has value.

Any thoughts?

Thanks.
 
try
target.MergeArea(1,1).Value

or .Text if you want a string of the value as formatted and displayed

Regards,
Peter T
 

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

Back
Top