web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to upload file to sharepoint using x++

(0) ShareShare
ReportReport
Posted on by 2

 

using System.IO;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using OfficeOpenXml.Table;
/// 
/// Vendor Wise Outstanding
/// 
class VendorWiseOutstandingCSV extends CSVExport
{
    BalanceAsOnDate          ToDate;
    DialogField		            dfToDate;

    FormBuildStringControl      fbscMultiVendCode;
    FormStringControl           fscMultiVendCode;
    container                   vendCodeCon;
    Str1260                     vendCode;
    SysLookupMultiSelectCtrl    multiVendCodeCtrl;

    VendTrans                           vendtrans;
    AmountCur                           remainAmountCur;
    real                                NotDueBalance,PrePaybalance,AdvToVend;
    OfficeOpenXml.ExcelRange            cell;
    OfficeOpenXml.ExcelRange            cells;
    int currentRow			   = 1;

    /// 
    /// buildQuery
    /// 
    /// query
    query buildQuery()
    {
       
        QueryBuildDataSource	 qbdsVendTable, qbdsInventSite;/
        Query query		      = new Query(queryStr(VendorWiseOutstanding));
        qbdsVendTable			= query.dataSourceTable(tableNum(VendTable));
        qbdsInventSite			= query.dataSourceTable(tableNum(InventSite));

        vendCode = con2Str(vendCodeCon);

        if(vendCode)
        {
            vendCode = strReplace(vendCode,';',',');
            qbdsVendTable.addRange(fieldNum(VendTable, AccountNum)).value(vendCode);
        }
        return query;
    }


    /// 
    /// export
    /// 
    /// boolean
    boolean export()
    {
        #Properties
        MemoryStream memoryStream = new MemoryStream();
  
        QueryRun							qr;
        VendTable                           vendTable;
       
        using (var package = new ExcelPackage(memoryStream))
        {
            var worksheets			   = package.get_Workbook().get_Worksheets();
            var CustTableWorksheet	   = worksheets.Add('Vendor Wise Outstanding');
             cells				   = CustTableWorksheet.get_Cells();
           
            // Report header start
            currentRow   ;

            cell  = null;
            cell  = cells.get_Item(currentRow, 1);
            cell.set_Value('Vendor Code');

            cell  = null;
            cell  = cells.get_Item(currentRow, 2);
            cell.set_Value('Vendor Name');

            cell  = null;
            cell  = cells.get_Item(currentRow, 3);
            cell.set_Value('Vendor Group');
 
            cell  = null;
            cell  = cells.get_Item(currentRow, 4);
            cell.set_Value('MSME Yes/No');
           
            cell  = null;
            cell  = cells.get_Item(currentRow, 5);
            cell.set_Value('Vendor Hold Status ');     

            qr = new queryRun(this.buildQuery());
   
            while (qr.next())
            {
                vendTable   =  qr.get(tableNum(VendTable));
                currentRow  ;
                    
                cell  = null;
                cell  = cells.get_Item(currentRow, 1);
                cell.set_Value(vendTable.AccountNum);

                cell  = null;
                cell  = cells.get_Item(currentRow, 2);
                cell.set_Value(vendTable.displayVendName(vendTable));
                 
                cell  = null;
                cell  = cells.get_Item(currentRow, 3);
                cell.set_Value(vendTable.VendGroup);

                cell  = null;
                cell  = cells.get_Item(currentRow, 4);
                cell.set_Value(vendTable.MSMEVendor);

                cell  = null;
                cell  = cells.get_Item(currentRow, 5);
                cell.set_Value(enum2Str(vendTable.Blocked));
                
                  
            }
            package.Save();
            file::SendFileToUser(memoryStream, filename   '.xlsx');
        }
        return true;
    }


}

I have created this excel report , now as I run this report fron it dialog from frontend , it downloads like this ,

 but requirement is It should be saved to sharepoint directly instead of downloading

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, I think it's because SendFileToUser, you can check this article

    impulztech.com/.../

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 509 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans