How can I get the count of cells in a range consisting of merged cells?

Hi,
I am trying to access the cell next to a named range, and insert text in that cell. The range consists of merged cells. Please help me.
I tried using:
sheet.Range[row, col+1].Text = "Text"

But this does not insert any text in the cell next to sheet.Range[row, col+1].

Thanks!

3 Replies

MW Melba Winshia Syncfusion Team February 22, 2007 02:03 PM UTC

Hi Emperor,

I am afraid. I created a sample with named range that contains Merged cells and inserted text to the next cell. But I was not able to reproduce the issue. Here is the test sample that I used to test this issue.

MergeCels.zip

Could you please take a look at the sample above and kindly let me know if you still find any problem, if not could you please modify this sample so that I can reproduce the issue. This would help me in investigating this issue further.

Thanks,
Melba


AD Administrator Syncfusion Team February 23, 2007 02:41 PM UTC

Hello Melba,
Thanks for your response. I looked at the code that you sent, but in your code, you are doing a merge on rows and not columns. I am merging columns within the same row. As such doing column+1 works in your case. I am merging 5 columns within the row, so if I do column+5 it will work, but I dont want to hardcode "5" in the code.
I hope I made my situation more clear.

Thanks
Gautam



>Hi Emperor,

I am afraid. I created a sample with named range that contains Merged cells and inserted text to the next cell. But I was not able to reproduce the issue. Here is the test sample that I used to test this issue.

MergeCels.zip

Could you please take a look at the sample above and kindly let me know if you still find any problem, if not could you please modify this sample so that I can reproduce the issue. This would help me in investigating this issue further.

Thanks,
Melba


MW Melba Winshia Syncfusion Team February 26, 2007 10:01 AM UTC

Hi Emperor,

You can use sheet.Range[row,column,lastrow,lastcol].Merge() to merge 5 columns within the same row and instead of using column+5 you can use lastcol+1 to insert text. Please refer the following code snippet which illustrates the above:

[C#]

int row=1;
int column=1;
int lastrow=1;
int lastcol=5;

// Merging cells (5 columns)
sheet.Range[row,column,lastrow,lastcol].Merge();

//Insert data
sheet.Range[row,lastcol+1].Text="Inserted Successfully";

Please refer the following sample which implements the above said feature:

MergeCels.zip

Kindly take a look and let me know if it meets your need.

Thanks,
Melba

Loader.
Up arrow icon