我编写了一个DXL函数,它从DOORS模块中读出一些属性和传出链接,并将其写入MS Excel表。 它工作正常。
现在我想将以下内容添加到DXL函数中:
当我打开DOORS模块并应用过滤器时 - > “链接”然后我可以说“通过Linkmodule”并选择一个特定的。 (我有德国的DOORS版本所以也许它被称为有点不同)
这是我目前的功能:
void WriteAllOutLinksToExcel (string sModuleName, string sBookName, string sSheetName)
{
OleAutoObj objExcel = oleGetAutoObject("Excel.Application")
OleAutoObj objBook
OleAutoObj objSheet = null
OleAutoArgs oleArgs = create
Object oCur
Module mCur
bool excelVisible
string sTemp = ""
string sResult = ""
string sNum
int iRow = 1
int iCount = 0
int iNum
Link lref
ModName_ targetMod
oleGet(objExcel, "Visible", excelVisible);
if (!excelVisible) olePut(objExcel,"visible",true);
sResult = oleGet(objExcel,"Workbooks", sBookName);
clear oleArgs;
put(oleArgs, sSheetName);
sResult = oleGet(objExcel, "Sheets", oleArgs, objSheet);
mCur = edit(sModuleName,false);
if(mCur != null)
{
View v = view("_ABC");
for oCur in mCur do
{
// Absolute object no..
sTemp = oCur."Absolute Number";
objCell = ExcelGetCell(objSheet, iRow, 1);
olePut(objCell,"Value",sTemp);
// Object text
sTemp = oCur."Object text";
objCell = ExcelGetCell(objSheet, iRow, 2);
olePut(objCell,"Value",sTemp);
// Links
iCount = null;
for lref in oCur -> "*" do {
targetMod = target lref;
iNum = targetAbsNo(lref);
sNum = " " iNum " ";
if(iCount == 0)
{
sTemp = fullName(targetMod) sNum;
}
else
{
sTemp = sTemp "\n" fullName(targetMod);
sTemp = sTemp sNum;
}
objCell = ExcelGetCell(objSheet, iRow, 3);
olePut(objCell,"Value",sTemp);
iCount ++;
}
iRow ++;
}
}
close(mCur);
oleCloseAutoObject (objExcel);
}
我在思考像for循环中的if语句,它说:“如果传递了linkmodule”abc“,则列出信息”Object number“&amp;”Object text“&amp; links ... < / p>
这可能吗?希望有人可以帮我这个吗?
答案 0 :(得分:0)
您需要做的就是将参数添加到您的输入中(我在此处添加了string LinkModName
),然后将"*"
添加到LinkModName
。 "*"
表示所有链接模块,但您可以将其替换为您要使用的任何特定链接模块的字符串名称。此外,您应确保将链接模块的完整路径传递给函数。
赞:/Project_Name/Folder_Name/Link_Module_Name
void WriteAllOutLinksToExcel (string sModuleName, string sBookName, string sSheetName, string LinkModName)
{
OleAutoObj objExcel = oleGetAutoObject("Excel.Application")
OleAutoObj objBook
OleAutoObj objSheet = null
OleAutoArgs oleArgs = create
Object oCur
Module mCur
bool excelVisible
string sTemp = ""
string sResult = ""
string sNum
int iRow = 1
int iCount = 0
int iNum
Link lref
ModName_ targetMod
oleGet(objExcel, "Visible", excelVisible);
if (!excelVisible) olePut(objExcel,"visible",true);
sResult = oleGet(objExcel,"Workbooks", sBookName);
clear oleArgs;
put(oleArgs, sSheetName);
sResult = oleGet(objExcel, "Sheets", oleArgs, objSheet);
mCur = edit(sModuleName,false);
if(mCur != null)
{
View v = view("_ABC");
for oCur in mCur do
{
// Absolute object no..
sTemp = oCur."Absolute Number";
objCell = ExcelGetCell(objSheet, iRow, 1);
olePut(objCell,"Value",sTemp);
// Object text
sTemp = oCur."Object text";
objCell = ExcelGetCell(objSheet, iRow, 2);
olePut(objCell,"Value",sTemp);
// Links
iCount = null;
for lref in oCur -> LinkModName do {
targetMod = target lref;
iNum = targetAbsNo(lref);
sNum = " " iNum " ";
if(iCount == 0)
{
sTemp = fullName(targetMod) sNum;
}
else
{
sTemp = sTemp "\n" fullName(targetMod);
sTemp = sTemp sNum;
}
objCell = ExcelGetCell(objSheet, iRow, 3);
olePut(objCell,"Value",sTemp);
iCount ++;
}
iRow ++;
}
}
close(mCur);
oleCloseAutoObject (objExcel);
}
希望这有帮助!