ApiRange Delete is not working

Hi,
I can not use the delete method inside api range.
I am using the collaborate onlyoffice from Kde on 7.0.0.6.
I copy pasted into a new spreadsheet and run it into a macro.
https://api.onlyoffice.com/docbuilder/spreadsheetapi/apirange/delete
It does create the values but does not delete the one in C4.
Hope there is an easy solution to this problem?
Thanks in advance.

DocumentBuilder version: onlyoffice 7.0.0.6
Installation method:
OS: Linux: Kde Collaborate

Hello @allon

Please pay attention to the description of the method:

Deletes the Range object.

Parameters:

Name Type Description
shift string Specifies how to shift cells to replace the deleted cells (“up”, “left”).

Basically, it deletes a value from specified range (cell C4 in sample) and replaces it with the value from cell C5 below with value 5.

If your final goal is to remove the value from specified cell or range, then use Clear method instead.

Hi,
Thanks for your answer. My goal is to remove several rows.
I have a spreadsheet where I want for example to remove rows 2 and 3.
I think that oRange.Delete(“up”); is the right command.
I tryed it on your demo and the 5 initially placed in C4 once the delete(“up”) is done.
On our version from onlyoffice the 5 does not move.
screenshot_macro_demo

The rest of my macro runs without problem.
Is there a special change to do or should I ask our administrator to update onlyoffice?
Thanks in advance!
Emmanuel

Now I see the final goal. Here is a sample on how to achieve it with Delete method combined with GetRows method to select all cells within specified rows:

var oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange("A1").SetValue("1");
oWorksheet.GetRange("A2").SetValue("2");
oWorksheet.GetRange("A3").SetValue("3");
oWorksheet.GetRange("A4").SetValue("4");
oWorksheet.GetRange("B1").SetValue("1");
oWorksheet.GetRange("B2").SetValue("2");
oWorksheet.GetRange("B3").SetValue("3");
oWorksheet.GetRange("B4").SetValue("4");
oWorksheet.GetRows("2").Delete("up");

I’m not quite sure if I understand the part about special change but we recommend using most recent version of the product in general. Please try out this approach and, if something goes wrong, then please update your instance and try again.

Hi,
The Delete method is definitly not working on our onlyoffice version and it works well on your demo page.
Thanks for the code I will definitly use it as soon as our administrator will have fixed the issue.
Emmanuel

1 Like