Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want a function like this:
to unmerge all merged cells in a Excel sheet and replaced all the merged cells value with the originally merged area value after unmerging action. I use the a cycle to fulfill it. But it's too too slowly if the Excel sheet data is a little big. The code (c# code) as below: for (int i=1; i<=Int32.Parse(ws.UsedRange.Rows.Count.ToString()) ;i++) { for (int j=1; j<=Int32.Parse(ws.UsedRange.Columns.Count.ToString ()); j++) { Excel.Range Range = (Excel.Range)ws.Cells[i,j]; if (bool.Parse(Range.MergeCells.ToString())) { int x = Int32.Parse(Range.MergeArea.Rows.Count.ToString()) ; int y = Int32.Parse(Range.MergeArea.Columns.Count.ToString ()); string TempValue = Range.Text.ToString(); Range.MergeArea.UnMerge(); for (int m = i; m<(i+x); m++) { for (int n = j; n<(j+y); n++) { Excel.Range TempRange = (Excel.Range)ws.Cells[m,n]; TempRange.set_Value( Type.Missing,TempValue); } } } } } Does Somebody have another idea to do it quickly?? Thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I unmerge an entire spread sheet in excel? | Excel Worksheet Functions | |||
sort spreadsheet, "merged cells" comes up. Find cells? Unmerge ? | Excel Discussion (Misc queries) | |||
Cannot merge or unmerge cells in Excel | Excel Discussion (Misc queries) | |||
UNMERGE two cells/rows in Excel | Excel Discussion (Misc queries) | |||
Can't unmerge merged cells programatically | Excel Programming |