Merge a column with same text

Posted by: cvetx on 8 September 2017, 1:49 pm EST

  • Posted 8 September 2017, 1:49 pm EST

    <P>I have a cloumn that has ten row on a sheet. Let's say there are only two text on the column which are "GM" and "Ford". Those are repeated on the sheet. How do I merge columns two see only a GM and Ford?</P>
    <P> Thanks.</P>
  • Replied 8 September 2017, 1:49 pm EST

    <p>Hello, </p><p>You may use the <b>merge </b>policy which when is set to Always, implies that cells within a row or column are merged when the cells have the same values. The below snippet will get the desired behavior:</p><blockquote><p>        FpSpread1_Sheet1.RowCount = 10<br>        FpSpread1_Sheet1.ColumnCount = 2<br>        FpSpread1.ActiveSheet.Cells(0, 0).Value = "GM"<br>        FpSpread1.ActiveSheet.Cells(0, 1).Value = "Ford"<br>        FpSpread1.ActiveSheet.Cells(1, 0).Value = "GM"<br>        FpSpread1.ActiveSheet.Cells(1, 1).Value = "GM"<br>        FpSpread1.ActiveSheet.Cells(2, 0).Value = "FORD"<br>        FpSpread1.ActiveSheet.Cells(2, 1).Value = "FORD"<br>        FpSpread1.ActiveSheet.Cells(3, 0).Value = "FORD"<br>        FpSpread1.ActiveSheet.Cells(3, 1).Value = "FORD"<br>        FpSpread1.ActiveSheet.Cells(4, 0).Value = "GM"<br>        FpSpread1.ActiveSheet.Cells(4, 1).Value = "GM"<br>        FpSpread1.ActiveSheet.Cells(5, 0).Value = "GM"<br>        FpSpread1.ActiveSheet.Cells(5, 1).Value = "Ford"<br>        FpSpread1.ActiveSheet.Cells(6, 0).Value = "GM"<br>        FpSpread1.ActiveSheet.Cells(6, 1).Value = "GM"<br>        FpSpread1.Sheets(0).SetColumnMerge(-1, FarPoint.Win.Spread.Model.MergePolicy.Always)</p></blockquote><p>Hope this helps.Thanks</p>
  • Replied 8 September 2017, 1:49 pm EST

    <P>Thanks for the reply and that worked out well. I have question here.</P>
    <P>--> The merged value is staying in the middle of the column and it moves by scrolling a sheet, so I can't see the value if the page is longer than display. Can I make it always stay on top of the column even though the sheet is scrolled?</P>
    <P> </P>
  • Replied 8 September 2017, 1:49 pm EST

    <p>Hello, </p><p>I am not sure, if i have understoond the requirement correctly, however if you wishes to freeze rows/column while scrolling the sheet(so that you can see the values, if page is longer), you may done so using the FrozenRowCount and FrozenColumnCount properties of the control.In case meets the requirement, then you may use the following:</p><blockquote><p>        FpSpread1.Sheets(0).FrozenColumnCount = 5<br>        FpSpread1.Sheets(0).FrozenRowCount = 5</p></blockquote><p>Thanks.</p>
  • Replied 8 September 2017, 1:49 pm EST

    <P>There is not a way to do this in the Spread for Windows Forms product.</P>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels