/// <summary>
/// Create and Download the Excel file.
/// </summary>
public void createAndDownloadExcelFile()
{
DocuFileSaveResult saveResult = DocuFileSave::promptForSaveLocation("@ApplicationPlatform:OfficeDefaultWorkbookFileName", "xlsx", null, "Testing excel export");
if (saveResult && saveResult.parmAction() != DocuFileSaveAction::Cancel)
{
saveResult.parmOpenParameters('web=1');
saveResult.parmOpenInNewWindow(false);
System.IO.Stream workbookStream = new System.IO.MemoryStream();
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
using (var package = new OfficeOpenXml.ExcelPackage(memoryStream))
{
var worksheets = package.get_Workbook().get_Worksheets();
var worksheet = worksheets.Add("First sheet");
var cells = worksheet.get_Cells();
var cell = cells.get_Item(1,1);
cell.set_Value("MyColumnTitle");
package.Save();
}
memoryStream.Seek(0, System.IO.SeekOrigin::Begin);
DocuFileSave::processSaveResult(memoryStream, saveResult); // Download the file.
}
}
How to read the existing file from local and load in to D365 in excel
ReplyDeletewhen writing the data in file we have required to merge the cells could you please help us with it
ReplyDeleteIs there any way to save this file into download folder without any other action from user such as select save/save and open?
ReplyDeleteThanks Hussain. Very helpful. :)
ReplyDeleteThanks very clear sample
ReplyDelete