Use the ReportResults.getReportMetadata method to retrieve report metadata. You can then use the “get” methods on the ReportMetadata class to access metadata values.
The following example retrieves metadata for a report.
// 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'); // Run a report Reports.ReportResults results = Reports.ReportManager.runReport(reportId); // Get the report metadata Reports.ReportMetadata rm = results.getReportMetadata(); System.debug('Name: ' + rm.getName()); System.debug('ID: ' + rm.getId()); System.debug('Currency code: ' + rm.getCurrencyCode()); System.debug('Developer name: ' + rm.getDeveloperName()); // Get grouping info for first grouping Reports.GroupingInfo gInfo = rm.getGroupingsDown()[0]; System.debug('Grouping name: ' + gInfo.getName()); System.debug('Grouping sort order: ' + gInfo.getSortOrder()); System.debug('Grouping date granularity: ' + gInfo.getDateGranularity()); // Get aggregates System.debug('First aggregate: ' + rm.getAggregates()[0]); System.debug('Second aggregate: ' + rm.getAggregates()[1]); // Get detail columns System.debug('Detail columns: ' + rm.getDetailColumns()); // Get report format System.debug('Report format: ' + rm.getReportFormat());