Monday, March 19, 2018

Export to Excel in D365

#AviFiles
SysOperationProgress progress1 = new SysOperationProgress();
int             row=1;
int             startrow;
int             col;
COM                 Crange;
COM                 CBorders;
COM                 CBorder;
;
DocuFileSaveResult saveResult = DocuFileSave::promptForSaveLocation("@ApplicationPlatform:OfficeDefaultWorkbookFileName", "xlsx", null, this.caption());
System.IO.Stream workbookStream = new System.IO.MemoryStream();  
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
saveResult.parmOpenParameters('web=1');
saveResult.parmOpenInNewWindow(false);
using (var package = new OfficeOpenXml.ExcelPackage(memoryStream))
{
     var sheet = package.get_Workbook().get_Worksheets();
     var worksheet = sheet.Add("First sheet");
     var cells = worksheet.get_Cells();
     OfficeOpenXml.Style.ExcelStyle style = cells.get_Item(row,1).get_style();
     OfficeOpenXml.Style.ExcelFont font = style.Font;
     OfficeOpenXml.Style.ExcelColor color = font.Color;
 cell = Cells.get_item(row,2);cell.set_Value("Entry Date");
            cellStyle = Cells.get_item(row, 2).get_style();
            style = cells.style;font  = style.font;color = font.color;
            color.SetColor(System.Drawing.Color::FromArgb(190,0,0));
     font.Size = 20;
     row++;
     Col = 1;
     cell = Cells.get_item(row,col);cell.set_Value(date2str(salesline.dlvdate,213,2,4,2,4,2));//j:10 line 1
     col++;
     package.save();
}
memoryStream.Seek(0, System.IO.SeekOrigin::Begin);
DocuFileSave::processSaveResult(memoryStream, saveResult);

No comments:

Post a Comment