how to create a downloadable excel file(xml) as a template in D365 Finance and OPeration using X++ in visual studio. Im planning to put the codes in a button(get template) in order to provide a template for the user. thanks!
how to create a downloadable excel file(xml) as a template in D365 Finance and OPeration using X++ in visual studio. Im planning to put the codes in a button(get template) in order to provide a template for the user. thanks!
Storing the file locally isn't related to the web server (and the code above). It's handled by the web browser on user's machine.
It's the same as if you're downloading a file from any other web server. You start downloading a file and choose where you want to store it on your local machine, or you have your web browser configured to automatically store downloaded files in a certain folder.
Hi Martin,
I tried this code out and there is a problem. The file is not saving in localstorage so probably theres an issue, I dont know if it is the code itself or it needs some functions that can download a file.
There are two separate requirements:
using OfficeOpenXml; ... using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { using (var package = new ExcelPackage(stream)) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Sheet1"); ExcelRange cell = worksheet.Cells.get_Item(1,1); cell.Value = 'It works'; package.Save(); } }
File::SendFileToUser(stream, 'data.xlsx');
Hi Ms Judy Jee,
Good day! I want to generate an xlsx file where the user can use as a template/format for sales quotation, and I want to save it automatically in a localdirectory once the user downloaded it.
Hi Sam,
Would you specify whether you want to create an excel file (xls or xlsx) or an xml file? These are two different file types. You may give more details for your requirements.