c++builder 中设置 excel表中单元格为超链接
今天刚搞定这个问题,奉献出来。
#include "Comobj.hpp"
#define OPG OlePropertyGet
#define OPS OlePropertySet
#define OFN OleFunction
#define OPR OleProcedure
//-------------------------------
....
Variant ExcelApp,WorkBook1,Sheet1,Range1;
try
{
ExcelApp=CreateOleObject ("Excel.Application");
}
catch(...)
{
ShowMessage("运行Exel出错!请确认安装了Office!");
return;
}
ExcelApp.OPS("Visible",true);//打开不显示EXCEL表
ExcelApp.OPG("WorkBooks").OleFunction("Add"); //打开一个新工作簿
WorkBook1=ExcelApp.OPG("ActiveWorkBook");//选择当前工作簿
Sheet1=WorkBook1.OPG("ActiveSheet");//选定当前工作页面
Range1=Sheet1.OPG("Range","A1:A1");//选定要设置的单元格
//Range1.OPG("Borders").OPS("Weight",1);
Sheet1.OPG("Hyperlinks").OFN("Add",Range1,"d:\\TDDOWNLOAD");//至此设定
......