function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
samita das 7samita das 7 

Fetch Report Data in Apex Class

I am fetching Standard Report in Apex class using Page reference and sending email to users having Report as excel in attachment . 
I am getting the Report in standard format . But is there any way to exclude the header and footer from the report . Please check the attached file for reference. How can I exclude row 1-14 and Grand Total records from Report.User-added imageUser-added image
Raj VakatiRaj Vakati
You need to uuse apex report API to do this once

Refer this link and sample code
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where 
    DeveloperName = 'Closed_Sales_This_Quarter'];
String reportId = (String)reportList.get(0).get('Id');

// Get the report metadata
Reports.ReportDescribeResult describe = Reports.ReportManager.describeReport(reportId);
Reports.ReportMetadata reportMd = describe.getReportMetadata();

// Override filter and run report
Reports.ReportFilter filter = reportMd.getReportFilters()[0];
Reports.ReportResults results = Reports.ReportManager.runReport(reportId, reportMd);
Reports.ReportFactWithSummaries factSum = 
System.debug('Value for November: ' + factSum.getAggregates()[0].getLabel());

// Override filter and run report
filter = reportMd.getReportFilters()[0];
results = Reports.ReportManager.runReport(reportId, reportMd);
factSum = (Reports.ReportFactWithSummaries)results.getFactMap().get('T!T');
System.debug('Value for October: ' + factSum.getAggregates()[0].getLabel());

Teju MeshramTeju Meshram
Can you provide the code for how to attached the file in excel format