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();
//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();
}
Comments
Bye.
Ramki.
Hi, could you tell me how did you solved that probelm??could you give me the source code?
thanks.
Best Regard!
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.
Ramki