i'm trying to duplicate a worksheet with its content into another new one.
In origin what i have is a table and i want to copy the worksheet with the table and its content.
In programming in PHP and i'm trying this:
$sheet = $graph->createRequest('GET', $originSheet)
->setReturnType(Model\WorkbookWorksheet::class)
->execute();
$sheet->setName($worksheetName);
$graph->createRequest('POST', $sheetUrl)
->setReturnType(Model\WorkbookWorksheet::class)
->attachBody($sheet)
->execute();
But the content is not duplicated, i just get a duplicated empty worksheet.
I tried to perform a GET to retrieve the origin table of origin worksheet, something like this:
$originSheetTables = $graph->createRequest('GET', $originSheetUrl)
->setReturnType(Model\WorkbookTable::class)
->execute();
But i don't know how to use the response of this request ($originSheetTables) to add into the new worksheet. I have tried this request with this approach:
$graph->createRequest('POST', $sheetUrl.'/'.$worksheetName.'/tables/add')
->attachBody($originSheetTables[0])
->execute();
But i'm getting a 400 error: "The request URI is not valid. The segment 'add' must be the (truncated...)"
Could you help me with this?
Thanks in advance.