Friday, October 30, 2009

Axapta : Formatting style in Excel


static void ExcelFormating(Args _args)
{
#Excel

SysExcelApplication excel;
SysExcelWorkbooks books;
SysExcelWorkbook book;
SysExcelWorksheet sheet;
SysExcelRange range;
SysExcelStyles styles;
SysExcelStyle style;
SysExcelInterior interior;
SysExcelFont font;
COM _char, _r;
;
excel = SysExcelApplication::construct();
excel.visible(true);
books = excel.workbooks();
book = books.add();
sheet = excel.activeSheet();
range = sheet.range('A1');
styles = book.styles();
style = styles.add('MyStyle');
interior = style.interior();
interior.color(WinApi::RGB2int(246, 233, 206));
font = style.font();
font.bold(true);
font.color(winapi::RGB2int(153, 204, 255));
range.style('MyStyle');
range.locked(true);
_r = range.comObject();
_char = _r.characters(1);
_char.insert('MyStyle');
}

No comments: