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 :
Microsoft Dynamics AX (Archived)

How to display Company Logo in Excel in Ax 2009 Reports

(0) ShareShare
ReportReport
Posted on by

Hi all, 

My client wants excel report. First i used COM and exported the values to excel. 

This was my code.


COM comApplication;
COM comWorkbooks;
COM comWorkbook;
COM comWorksheet;
COM comShapes;

COMVariant variant = new COMVariant();
COMVariant xpos = new COMVariant();
COMVariant ypos = new COMVariant();
COMVariant state = new COMVariant();
COMVariant width = new COMVariant();
COMVariant height = new COMVariant();

SysExcelWorksheet excelWorksheet;
SysExcelCells excelCells;
;

//Create the Excel app and grab the workbooks
comApplication = new COM('Excel.application');
comWorkBooks = comApplication.workbooks();

//Wrap the rest in an exception to make sure excel is closed
try
{
//Create a new workbook and get a reference to it
variant.int(-4167);
comWorkBook = comWorkBooks.add(variant);
comWorkSheet = comApplication.activeSheet();
//Add some text to the worksheet
excelWorksheet = SysExcelWorkSheet::construct(MSOfficeVersion::Office2000, comWorksheet);
excelCells = excelWorksheet.cells();
excelCells.item(10,1).value("Hello world");

//Set up image parameters
variant.bStr("c:\\temp\\companyLogo.bmp");
xpos.int(1);
ypos.int(1);
state.int(1);
width.int(100);
height.int(100);
//Add the image to the worksheet
comShapes = comWorkSheet.shapes();
comShapes.addPicture(variant,xpos,ypos,state,state,width,height);

//Autofitt and protect the sheet
excelworksheet.columns().autoFit();
excelWorksheet.protect('',true,true);

//Save the sheet and close the app
comWorkBook.saveas("c:\\temp\\hello.xls");
comWorkBooks.close();
comApplication.quit();
}
catch(Exception::Error)
{
//Force app to quit
comWorkBook.saveas("c:\\temp\\hello.xls");
comWorkBooks.close();
comApplication.quit();
}

But performance is very very low.

Then i created new AX 2009 report and print the output in File(Excel) rather than Screen.

i.e, this.printjobsettings().setTarget(PrintMedium::file);

I am getting all the values with good performance but i can not able to display my company Logo in excel. 

It would be very helpful if anyone could help me on the same.

Thanks in advance.

*This post is locked for comments

I have the same question (0)

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans