Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

To create the SSRS excel report in f&o

(3) ShareShare
ReportReport
Posted on by 1,678
I need to create the excel report from ssrs report , when i generate it should generate the downlodable excel file in download without opening .
can anyone help me on this how to implement this , 
which classes will envolved and should I need report design .
can anyone guide me on this  i am getting the data from purchase order.
 
thanks,
 
  • Adis Profile Picture
    5,149 Super User 2025 Season 1 on at
    To create the SSRS excel report in f&o
    Hi,
     
    To answer your question, it is achievable through SSRS and its nothing wrong with it. 
    ER reporting gives you some benefits (and also drawbacks tbh).
     
    • Designing of the format (excel) is much easier in ER.
    • Changes are done within the application, no need for releases. So anything that is not specified by the user\consultant is forgiven as you dont have to deploy anything.
    You need to know how it works.
    Something that helped me a lot to understand was this video
     
     

    Kind regards, Adis

     

    If this helped, please mark it as "Verified" for others facing the same issue

    Keep in mind that it is possible to mark more than one answer as verified

  • Martin Dráb Profile Picture
    234,648 Most Valuable Professional on at
    To create the SSRS excel report in f&o
    Your code and your requirement don't match at all. The method renderReportToByteArray() has nothing to do with opening the report on the screen; its purpose is to store the rendered report in memory (technically in a byte array), so you can later give it to the user for download.
     
    Also, please give us more information about the error, such as the stack trace of the exception.
  • Dineshkarlekar Profile Picture
    1,678 on at
    To create the SSRS excel report in f&o
    I am getting this error can you help me how can i open the report on the screen , i am not getting  like what path i have to put here  
     reportBytes = srsProxy.renderReportToByteArray('PurchLineExcel.Report', // report design name
                                                            paramArray,
                                                            SRSReportFileFormat::Excel,
                                                           'PurchaseLines.xlsx'
                                                           );
     
    The menu item with name summaryreport could not be opened.
    • The path of the item 'summaryReport.Report' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash.
  • Martin Dráb Profile Picture
    234,648 Most Valuable Professional on at
    To create the SSRS excel report in f&o
    You forgot to tell us what problem you have with your code.
  • Dineshkarlekar Profile Picture
    1,678 on at
    To create the SSRS excel report in f&o
    hi everyone, 
    I have done code , i need to get the report open on front end in excel format ,
    please let me know where i have to correct in the code.below is my code.
     class summaryReportController  extends SrsReportRunController
    {
        // Main method to trigger the report generation
        public static void main(Args _args)
        {
            summaryReportController controller = new summaryReportController();
            controller.parmReportName(ssrsReportStr(summaryReport, Report));  // Specify the report name
            controller.startOperation();
        }
    
        // Override startOperation to customize report export behavior
        public SysOperationStartResult startOperation()
        {
            SrsReportRunController controller = new SrsReportRunController();
            SRSPrintDestinationSettings printSettings;
            SRSProxy srsProxy = new SRSProxy();
            str reportNameExcel = 'PurchLineExcel.Report';  // SSRS report name
            str fileName = 'PurchaseLines.xlsx';      // Excel file name
            System.Byte[] reportBytes;
            System.IO.MemoryStream memoryStream;
    
            // Set the report name
            controller.parmReportName(reportNameExcel);
    
            // 1. Configure print destination for Excel
            printSettings = controller.parmReportContract().parmPrintSettings();
            printSettings.printMediumType(SRSPrintMediumType::File);  // Output to file
            printSettings.fileFormat(SRSReportFileFormat::Excel);  // Excel file format
            printSettings.overwriteFile(true);  // Overwrite if file exists
            printSettings.parmFileName(fileName);  // Set file name
    
    
            Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] paramArray;
            paramArray = new Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[0]();
    
            // 2. Render the report as byte array
            reportBytes = srsProxy.renderReportToByteArray('PurchLineExcel.Report', // report design name
                                                            paramArray,
                                                            SRSReportFileFormat::Excel,
                                                           'PurchaseLines.xlsx'
                                                           );
    
            // 3. Send the Excel report to the client
            if (reportBytes)
            {
                memoryStream = new System.IO.MemoryStream(reportBytes);
    
                File::SendFileToUser(
                    memoryStream,
                    fileName,
                    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
                );
            }
            else
            {
                error("Failed to generate the Purchase Line report.");
            }
            return 0;
        }
    
    }
     
    class SummaryReportDP extends SrsReportDataProviderBase
    {
        PurchLine                purchLine;
        PurchTable               purchTable;
        SummaryReportTemp    summaryReportTemp; // Temporary table to store report data
         
        
        [ SRSReportDataSetAttribute(tableStr(summaryReportTemp)) ]
        public  summaryReportTemp getsummaryReportTemp()
        {
            return summaryReportTemp;
        }
    
        public void processReport()
        { 
    
            Map                     poSummaryMap = new Map(Types::String, Types::Record);
            summaryReportTemp   tempRec;
            str                     key;
    
            // Step 1: Aggregate quantities, prices, amounts per PurchId
            while select purchLine
                join purchTable
                where purchTable.PurchId == purchLine.PurchId
            {
                key = purchLine.PurchId;
    
                if (poSummaryMap.exists(key))
                {
                    tempRec = poSummaryMap.lookup(key);
                    tempRec.PurchQty    += purchLine.PurchQty;
                    tempRec.LineAmount  += purchLine.LineAmount;
                    tempRec.PurchPrice  += purchLine.PurchPrice;
                }
                else
                {
                    tempRec.clear();
                    tempRec.PurchId     = purchLine.PurchId;
                    tempRec.PurchQty    = purchLine.PurchQty;
                    tempRec.LineAmount  = purchLine.LineAmount;
                    tempRec.PurchPrice  = purchLine.PurchPrice;
                    tempRec.VendorId    = purchTable.OrderAccount;
                    tempRec.VendorName  = VendTable::find(purchTable.OrderAccount).name();
    
                    poSummaryMap.insert(key, tempRec);
                }
            }
    
            // Step 2: Insert aggregated records into the temp table
            MapEnumerator enumerator = poSummaryMap.getEnumerator();
            while (enumerator.moveNext())
            {
                tempRec = enumerator.currentValue();
                tempRec.insert();
            }
        }
    
    }
     
  • Dineshkarlekar Profile Picture
    1,678 on at
    To create the SSRS excel report in f&o
    hi Martin 
    Thanks for reply ,
     
    Should i use the same classes which i use to develope the ssrs report  the the report design .
    Is it all same except the print to excel code which i am using to convert the report in to excel file .
    I will provide it download path file location. please guide me on this.
     
    thanks,
    Dinesh.
     
     
  • Dineshkarlekar Profile Picture
    1,678 on at
    To create the SSRS excel report in f&o
     
    can you please provide me link if i have to use electronic report .
    Do you think it is not possible with ssrs ?
    i am using visual studio 2019.
     
    thanks,
     
    Dinesh
  • Martin Dráb Profile Picture
    234,648 Most Valuable Professional on at
    To create the SSRS excel report in f&o
    The web server running in Azure can't connect to user's machine and put a file to the Download folder. What could happen is that the file is given to the user for download and the user may have the browser configured to automatically download files to that folder.
     
    Of course, it requires that the report is generated in user's session, but often users want to run reports in a batch, especially if it's a periodic report ("I want the data ready just before the shift starts") or it's long-running. A better way may be storing the file at a location where users can access it (and download it from if needed), i.e. the print archive.
  • Jonas "Jones" Melgaard Profile Picture
    4,571 Super User 2025 Season 1 on at
    To create the SSRS excel report in f&o
    Just to add to what Adis said, Microsoft has announced the removal of SQL Server Reporting Services from SQL server 2025, so while it might not affect F&O in the short run the writing is on the wall in terms of deprecation of SSRS.
    If I were you I'd try to avoid creating new SSRS reports.
  • Adis Profile Picture
    5,149 Super User 2025 Season 1 on at
    To create the SSRS excel report in f&o
    Hi,
     
    Just out of curiosity. Can you tell me why you dont use electronic reporting (ER) for such a report?
    I am just wondering why people use SSRS and not ER, which doesnt mean ER is better. Both has its place.
     

    Kind regards, Adis

     

    If this helped, please mark it as "Verified" for others facing the same issue

    Keep in mind that it is possible to mark more than one answer as verified

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 565

#2
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2025 Season 1

Product updates

Dynamics 365 release plans