0

我编写了一个 DXL 函数,它从 DOORS 模块中读取一些属性和传出链接并将其写入 MS Excel 表。它工作正常。

现在我想在 DXL 函数中添加以下内容:

当我打开一个 DOORS 模块并应用过滤器 --> “链接”时,我可以说“通过链接模块”并选择一个特定的。(我有德国的 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 语句:“如果传递了链接模块“abc”,则列出信息“对象编号”和“对象文本”和链接......

这可能吗?希望有人能帮我解决这个问题吗?

4

1 回答 1

0

您需要做的就是将参数添加到您的输入(我string LinkModName在此处添加)而不是"*"put 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);
}

希望这可以帮助!

于 2013-10-23T11:35:12.563 回答