Images to Excel

kram1976
Member Posts: 19
Hi,
Does anyone know to put images into excel sheet using x++ code.
Please revert back.
Thanks.
Ramki.
Does anyone know to put images into excel sheet using x++ code.
Please revert back.
Thanks.
Ramki.
Ramakrishnan
0
Comments
-
I had solved the problem.
Bye.
Ramki.Ramakrishnan0 -
Hi,
This is the source code....
static void ImagesToExcel(Args _args)
{
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("D\\Ramki\Images\xyz.gif");
xpos.int(1);
ypos.int(1);
state.int(1);
width.int(50);
height.int(50);
//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:\\Nature1.xls");
comWorkBooks.close();
comApplication.quit();
}
catch(Exception::Error)
{
//Force app to quit
comWorkBook.saveas("c:\\Nature1.xls");
comWorkBooks.close();
comApplication.quit();
}
}
I Hope this would serves the need.
RamkiRamakrishnan0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions