I am trying to extract some reports i have created through an external API but i can't seem to find a way how to.
Any assistance would be appreciated
I am trying to extract some reports i have created through an external API but i can't seem to find a way how to.
Any assistance would be appreciated
Yes you can. One way can be similar to this code.
procedure ExportReport() responseText: Text
var
ResponseObject: JsonObject;
begin
ResponseObject.Add('reportName', 'Inventory List');
ResponseObject.Add('extension', 'xlsx');
ResponseObject.Add('content', RunReport());
ResponseObject.WriteTo(responseText);
end;
local procedure RunReport(): Text
var
InventoryListReport: Report "Inventory - List";
TempBlob: Codeunit "Temp Blob";
Base64Convert: Codeunit "Base64 Convert";
FileText: Text;
MyOutStream: OutStream;
MyInStream: InStream;
begin
//SetTableView and SetReqFilter if required
TempBlob.CreateOutStream(MyOutStream);
InventoryListReport.UseRequestPage(false);
InventoryListReport.SaveAs('', ReportFormat::Excel, MyOutStream);
TempBlob.CreateInStream(MyInStream);
FileText := Base64Convert.ToBase64(MyInStream);
exit(FileText);
end;
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156