Hi All,
On using the below code (in link):
https://dynamicsuser.net/ax/f/developers/16803/how-can-i-export-image-to-excel
I am getting 2 excels in 1 excel, the header pic is appearing and in another excel, my report data is appearing. Please suggest ASAP.
I’m sorry, but I don’t understand what you’re saying. Could you please explain the observed behavior once more with a little more details and then show us your actual code?
private void createExcelFile()
{
COM comApplication;
COM comWorkbooks;
COM comWorkbook;
COM comWorksheet;
COM comShapes;
COM comShape;
COMVariant variant = new COMVariant();
COMVariant horizPos = new COMVariant();
COMVariant vertPos = new COMVariant();
COMVariant state = new COMVariant();
COMVariant width = new COMVariant();
COMVariant height = new COMVariant();
startDateValue = FcsDateTimeAPI::convertFromDateLocal(startDate);
EndDateValue = FcsDateTimeAPI::convertFromDateLocal(endDate);
//EndDateValue = DateTimeUtil::newDateTime(EndDateValue+1,0)
EndDateValue = FcsDateTimeAPI::addDay(EndDateValue, 1);
excel = SysExcelApplication::construct();
workbooks = excel.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
excel2 = SysExcelApplication::construct();
workbooks2 = excel2.workbooks();
workbook2 = workbooks2.add();
worksheets2 = workbook2.worksheets();
worksheets.add();
worksheets.add();
worksheets.add();
worksheets.add();
worksheets.add();
worksheets.add();
worksheets.add();
worksheets2.add();
worksheets2.add();
worksheets2.add();
worksheets2.add();
worksheets2.add();
worksheets2.add();
worksheets2.add();
//logic
comApplication = new COM(‘Excel.application’);
comWorkBooks = comApplication.workbooks();
variant.int(-4167);
comWorkBook = comWorkBooks.add(variant);
comWorkSheet = comApplication.activeSheet();
//Add some text to the worksheet
worksheet = SysExcelWorkSheet::construct(MSOfficeVersion::Office2010, comWorksheet);
//Set up image parameters
variant.bStr(“file location”);
horizPos.int(5);
vertPos.int(5);
state.int(5);
width.int(100);
height.int(100);
//Add the image to the worksheet
comShapes = comWorkSheet.shapes();
comShapes.addPicture(variant,horizPos,vertPos,state,state,width,height);
}