Inserting Hidden Rows

Posted by: fpsteve14 on 8 September 2017, 3:21 pm EST

  • Posted 8 September 2017, 3:21 pm EST

    I'm using Spread Studio on .NET 2.0 and I have some problems with inserting new rows which include hidden ones. More specifically, I want to click a button to insert 4 rows in which there are 2 hidden rows that contain reference data. Although the rows are set hidden in the excel file, when I insert rows and do CopyRange onto the new four rows all the rows which are supposed to be hidden are all displayed. Shouldn't the properties hidden of the original rows pass onto the new ones?
  • Marked as Answer

    Replied 8 September 2017, 3:21 pm EST


    Are you specifying true for the dataOnly parameter to CopyRange?
    I tried this code and it seems to work well:

    for (int r = 0; r < 4; r++)
    for (int c = 0; c < 5; c++)
    Cell cell = fpSpread1_Sheet1.Cells[r, c];
    fpSpread1_Sheet1.SetValue(r, c, cell.ToString(cell));
    fpSpread1_Sheet1.Rows[1, 2].Visible = false;
    fpSpread1_Sheet1.AddRows(0, 4);
    fpSpread1_Sheet1.CopyRange(4, -1, 0, -1, 4, -1, false);

  • Replied 8 September 2017, 3:21 pm EST

    I have set false for dataOnly and I have tried both CopyRange and MoveRange methods. Note that I load an excel file through OpenExcel method and thus I am not changing the spread sheet of fpSpread but rather the sheet of the excel file that contains multiple sheets.
  • Replied 8 September 2017, 3:21 pm EST

    Hi Sean,

    It's all good now, the only problem was that I used fpSpread1_Sheet1.CopyRange(4, 0, 0, 0, 4, -1, false); instead of fpSpread1_Sheet1.CopyRange(4, -1, 0, -1, 4, -1, false);

    I copied the height of the rows from the first column rather than indicate it not to do so. Simply by changing fromCol to -1 and toCol to -1, I have resolved the problem.

    Thank you very much!

    Kind regards,
Need extra support?

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

Learn More

Forum Channels