Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get the value of a merged cell using c#

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.xlRangeValu eDefault);
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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to get the value of a merged cell using c#

try
target.MergeArea(1,1).Value

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

Regards,
Peter T

"Issac" wrote in message
...
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.xlRangeValu eDefault);
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
Very Basic Problem - Merged Cell Equals Contents of a Single Cell jollynicechap Excel Worksheet Functions 3 December 29th 06 08:16 PM
how do i link merged cells to a merged cell in another worksheet. ibbm Excel Worksheet Functions 3 April 27th 06 11:40 PM
How to copy single cell into cell that is merged from two cells? Rod Excel Discussion (Misc queries) 3 January 22nd 06 09:24 PM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


All times are GMT +1. The time now is 10:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"