为什么相对路径运行不正确?
从excel中读取数据,代码如下:
Variant Ex,Wb,Sh1;
Ex=Variant::CreateObject("Excel.Application");
Ex.PG("WorkBooks").PR("Open",ExtractFilePath(Application->ExeName)+"a.xls");
Wb=Ex.PG("ActiveWorkBook"); Sh1=Wb.PG("ActiveSheet");
Edit2->Text=Sh1.PG("Cells",2,1).PG("Value");
Wb.PR("Close");
但若改为绝对路径则可以正确运行.
请教大家,先谢谢了啊
[解决办法]
//带入的参数是char * 类型的//Ex.PG("WorkBooks").PR("Open",ExtractFilePath(Application->ExeName)+"a.xls");AnsiString FileName = ExtractFilePath(Application->ExeName)+"a.xls";Ex.PG("WorkBooks").PR("Open",FileName.c_str());