将表记录导入到Excel完整代码
2008-10-24 14:30:53 来源:WEB开发网void clicked()
{
#Excel
HWND HWND;
SysExcelapplication excel;
SysExcelWorkbooks books;
SysExcelWorkbook book;
SysExcelWorksheets sheets;
SysExcelWorksheet sheet;
SysExcelRange columns;
SysExcelRange column;
SysExcelCells cells;
SysExcelCell cell;
SysExcelStyle ExcelStyle;
SysExcelFont ExcelFont;
SysExcelFormatCondition FormatCondition;
//定义要导出的表.
BeMarked _mark;
int i = 1;
//构造Excel表结构.
excel = SysExcelApplication::construct();
books = excel.workbooks();
book = books.add();
Sheets = book.worksheets();
sheet = sheets.itemFromNum(1); //控制到第几个工作表.
sheet.name("abc");
super();
//字段名:
sheet.cells().item(1,1).value("STR"); // item(row,column)
sheet.cells().item(1,2).value("INT");
sheet.cells().item(1,3).value("Choose");
sheet.cells().item(1,4).value("company");
//导入字段值.
while select _mark
{
excel.visible(true);
sheet.cells().item(i+1,1).value(_mark.Str);
sheet.cells().item(i+1,2).value(_mark.Int);
// sheet.cells().item(3,1).value().handle(); //?
// ExcelFont.bold(true);
sheet.cells().item(i+1,3).value(_mark.choose);
sheet.cells().item(i+1,4).value(_mark.dataAreaId);
i++;
}
}
更多精彩
赞助商链接