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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Append/Update excel file from Azure blob in D365

(0) ShareShare
ReportReport
Posted on by 252

Hi,

I am trying to get an excel file from Azure blob and trying to add a new worksheet in the file using the below code in D365. While on debugging mode, I can see that new worksheet is getting added with the required cells and the data but post the execution process the new worksheet is not displayed in the file when I open it. Please let me know if there are any suggestions!

str downloadUrl = DMFDataPopulation::getAzureBlobReadUrl(str2Guid(fileId));

System.IO.Stream stream = File::UseFileFromURL(downloadUrl);

using (var package = new ExcelPackage(stream))
{
var currentRow = 1;

var worksheets = package.get_Workbook().get_Worksheets();
var dataTemplateWorksheet = worksheets.Add('Description');
var cells = dataTemplateWorksheet.get_Cells();
OfficeOpenXml.ExcelRange cell = cells.get_Item(currentRow, 1, currentRow, 7);

System.String value = 'testdata';
cell.set_Value(value);
cell.Merge = true;
package.Save();
DocuFileSave::saveFileAs(stream, 'test', 'xlsx');
}

Thanks,

Suren.

I have the same question (0)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Suren_G,

    You need to save a modified package to another stream

    System.IO.MemoryStream stream1 = new System.IO.MemoryStream();
     
    package.SaveAs(stream1);
     
    DocuFileSave::saveFileAs(stream1, 'test', 'xlsx');

  • Suren_G Profile Picture
    252 on at

    Thanks Sergei.. It is working fine with another stream.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans