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.