Hello everyone, I have a project in DOORS which has multiple requirements modules and I want to export all the SRS (requirements) modules to excel using DXL script. Right now, I am able to export only one module at a time. I want to export all modules at once. My main motive is to generate a list of parameters in particular column of each and every module under one project. Please suggest the solution. I am using DOORS 9.3 Thanks in advance, Manoj ManojBharat - Wed Apr 29 17:32:50 EDT 2015 |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module I'm not sure I understand what you're trying to do. "generate a list of parameters..." Do you mean you want to get the values of a particular set of Attributes from the Objects in the Modules? |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module woodpryan - Wed Apr 29 18:50:41 EDT 2015 I'm not sure I understand what you're trying to do. "generate a list of parameters..." Do you mean you want to get the values of a particular set of Attributes from the Objects in the Modules? yes. your understanding is correct. But I want to generate for multiple modules at one go. |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module ManojBharat - Wed Apr 29 19:25:39 EDT 2015 yes. your understanding is correct. But I want to generate for multiple modules at one go. OK. First, take this code. Call it WriteToExcel.dxl
#include <utils/doctools/itfutil.inc>
checkPlatform("Microsoft Excel");
OleAutoObj objExcel = null;//the MS Excel application
OleAutoObj objWorkbooks = null;//the collection of Workbooks from this instance of the application
OleAutoObj objWorkbook = null;//the active workbook
OleAutoObj objSheet = null;//the active sheet
OleAutoObj objCell = null;//the active cell
OleAutoObj objSel = null;//the selection (cursor)
OleAutoArgs objArgBlock = create();//the list of arguments to VBA functions
Skip sheetList = null;//the list of DxlObject sheet representations, key = sheetName, value = DxlObject sheet
DxlObject objCurrentSheet = null;//the currently active DxlObject sheet
const string i_rowNum = "rowNum";//current row number of a sheet
const string i_colNum = "colNum";//current column number of a sheet
const string i_maxCols = "maxCols";//the number of columns to write before moving to the next row of the sheet
const string s_sheetName = "sheetName";//the name of a sheet
const string i_sheetNum = "sheetNum";//the index of a sheet into the VBA Sheets collection, not the key to the sheetList Skip
/* Function: incrementSheetNumbers()
Purpose: goes through the list of sheets and increments all the
sheet numbers by one
*/
void incrementSheetNumbers()
{
DxlObject objSheet = null;
if(null == sheetList)
return;
for objSheet in sheetList do
{
incrementIntValue(objSheet, i_sheetNum);
}
}
/* Function: addNewSheet(string, int)
Purpose: adds a new sheet to the MS Excel workbook having the given name
and maximum number of columns. The most recently added sheet is
always sheet number one, so this function will also call incrementSheetNumbers
to increment the numbers of all the sheets that are already in the sheetList
Parameters: the sheet name, the maximum number of columns that may be written before the next row
*/
void addNewSheet(string sheetName, int maxCols)
{
DxlObject dxlObjSheet = new();
OleAutoObj objSheets = null;
if(null == sheetList)
sheetList = createString();
dxlObjSheet-> i_rowNum = 1;//Initialize the row to begin with 1
dxlObjSheet-> i_colNum = 1;//Initialize the column to begin with 1
dxlObjSheet-> i_maxCols = maxCols;//Set the max columns to the value passed in
dxlObjSheet-> s_sheetName = sheetName;//Set the sheet name to be the value passed in
dxlObjSheet-> i_sheetNum = 1;//Initialize the sheet number to be 1
incrementSheetNumbers();
put(sheetList, (string dxlObjSheet->s_sheetName), dxlObjSheet);//Puts the passed-in value of the sheet name into the skip as the key
objCurrentSheet = dxlObjSheet;
oleGet(objWorkbook, cPropertySheets, objSheets);
if(null != objSheets)
{
oleMethod(objSheets, cMethodAdd);
clear(objArgBlock);
put(objArgBlock, 1);
oleGet(objSheets, cMethodItem, objArgBlock, objSheet);
if(null == objSheet)
{
logError("Problem retrieving a handle on the new sheet named " sheetName);
return;
}
olePut(objSheet, cPropertyName, sheetName);
}
}
/* Function: addSheetToList(string, int)
Purpose: instantiates a new DxlObject representing the necessary information
about an MS Excel sheet (current row and column, maximum columns,
sheet name and number) and adds it to the Skip list of DxlObject sheets.
Creates the list if it doesn't have anything in it yet.
Parameters: the sheet name, the sheet number
*/
void addSheetToList(string sSheetName, int iSheetNum)
{
DxlObject dxlObjSheet = new();
if(null == sheetList)
sheetList = createString();
dxlObjSheet-> i_rowNum = 1;//Initialize the row to begin with 1
dxlObjSheet-> i_colNum = 1;//Initialize the column to begin with 1
dxlObjSheet-> i_maxCols = 1;//Set the max columns to the value passed in
dxlObjSheet-> s_sheetName = sSheetName;//Set the sheet name to be the value passed in
dxlObjSheet-> i_sheetNum = iSheetNum;//Initialize the sheet number to be 1
put(sheetList, (string dxlObjSheet->s_sheetName), dxlObjSheet);//Puts the passed-in value of the sheet name into the skip as the key
objCurrentSheet = dxlObjSheet;
}
/* Function: initSheetList()
Purpose: initializes the list of sheets, storing the three sheets
that MS Excel begins with in the sheets list as DxlObjects
having names, sheet numbers, current rows/columns, and max columns
*/
void initSheetList()
{
OleAutoObj objSheets = null;
string sSheetName = null;
int numSheets = 0;
int count = 0;
oleGet(objWorkbook, cPropertySheets, objSheets);
if(null == objSheets)
return;
oleGet(objSheets, cPropertyCount, numSheets);
for(count = 1; count <= numSheets; count++)
{
clear(objArgBlock);
put(objArgBlock, count);
oleGet(objSheets, cMethodItem, objArgBlock, objSheet);
if(null == objSheet)
{
logError("Could not retrieve a sheet with index " count " from the list of sheets.");
return;
}
oleGet(objSheet, cPropertyName, sSheetName);
addSheetToList(sSheetName, count);
}
}
/* Function: initExcel()
Purpose: opens excel and initializes global excel variables
Return: success
*/
bool initExcel()
{
objExcel = connectToApp(cObjExcelApplication, ("Excel"));
if(null == objExcel)
{
logError("Could not connect to the Excel application. Is it installed?");
return false;
}
makeVisible(objExcel);
// get workbooks collection
checkRes(oleGet(objExcel, cPropertyWorkbooks, objWorkbooks));
if(null == objWorkbooks)
{
logError("String Unable to get workbooks collection");
return false;
}
// add one
checkRes(oleMethod(objWorkbooks, cMethodAdd));
// get active workbook
checkRes(oleGet(objExcel, cPropertyActiveWorkbook, objWorkbook));
if(null == objWorkbook)
{
logError("Unable to get active workbook");
return false;
}
initSheetList();
//get active sheet
checkRes(oleGet(objWorkbook, cPropertyActiveSheet, objSheet));
if(null == objSheet)
{
ack("String Unable to get active sheet");
return false;
}
oleGet(objExcel, cPropertySelection, objSel);
if(null == objExcel)
{
ack("Could not get a handle on the Active Selection.");
return false;
}
return true
}
/* Function: intToCol(int)
Purpose: returns the column letter represented by the integer
passed to the function.
Parameters: the column number
Return: the column letter
*/
string intToCol(int i)
{
string s = null;
if ((i >= 1) && (i <= 256))
{
int d1 = (i-1) / 26;
int d2 = (i-1) % 26;
if (d1 > 0)
s = charOf( d1-1 + intOf('A')) "";
s = s charOf( d2 + intOf('A')) "";
}
else
{
if (i > 256)
ack("Too many columns");
else
ack("Invalid column reference " s);
return s;
}
return s;
}
/* Function: setCell(int, int, string)
Purpose: sets the contents of the specified cell at row and column
with the value stored in the specified string.
Parameters: the row, the column, the data
*/
void setCell(int row, int col, string s)
{
closeIfNonNull(objCell);
clear(objArgBlock);
put(objArgBlock, (intToCol col) row (NLS_("")));
checkRes(oleGet(objSheet, cMethodRange, objArgBlock, objCell));
if(null objCell)
{
ack LS_("String_Unable_to_get_cell_object",NLSTEMP_("Unable to get cell object"));
halt();
}
oleMethod(objCell, cMethodSelect);
oleGet(objExcel, cPropertySelection, objSel);
/*Excel considers a string starting with the following characters:-
An equal character (=), a plus character (+), a minus character (-) or the (@) character
to be the start of an excel formula, hence it throws an error "OLE method failed".
To avoid this we append "'" before the string.
Also, "numbers-numbers" or "numbers-numbers-numbers" (Eg: 14-3, 14-10-17) will be intrepreted as "Date" in Excel.
So we append "'" before those strings also.*/
Regexp dateCheck = regexp (NLS_("^([0-9]+-)+[0-9]+$"));
if( s[0:0] == (NLS_("=")) || s[0:0] == (NLS_("+")) || s[0:0] == (NLS_("-")) || s[0:0] == (NLS_("@")) || dateCheck s )
{
s = (NLS_("'")) s;
}
checkRes(olePut(objCell, cPropertyValue, s));
}
/* Function: cleanExcel()
Purpose: disconnects from the Excel application, deletes
any global OleAutoObj variable and the argument block.
*/
void cleanExcel()
{
DxlObject dxlObj = null;
disconnectFromApp(objExcel);
closeIfNonNull(objExcel);
closeIfNonNull(objWorkbooks);
closeIfNonNull(objWorkbook);
closeIfNonNull(objSheet);
closeIfNonNull(objCell);
closeIfNonNull(objSel);
delete(objArgBlock);
if(null != sheetList)
{
for dxlObj in sheetList do
{
delete(dxlObj);
}
}
delete(sheetList);
}
/* Function: getColumn(string)
Purpose: returns the column of the specified string.
Parameters: the column letter
Return: the column
*/
OleAutoObj getColumn(string col)
{
OleAutoObj objColumns = null;
OleAutoObj objColumn = null;
oleGet(objSheet, cPropertyColumns, objColumns);
if(null != objColumns)
{
clear(objArgBlock);
put(objArgBlock, col);
oleGet(objColumns, cMethodItem, objArgBlock, objColumn);
}
closeIfNonNull(objColumns);
return objColumn;
}
/* Function: getColumn(int)
Purpose: returns the column of the specified number
Parameters: the column number
Return: the column
*/
OleAutoObj getColumn(int col)
{
return getColumn(intToCol(col));
}
/* Function: setWorksheetWrapText(bool)
Purpose: sets the text wrapping on the current column
Parameters: Whether or not to wrap text
*/
void setWorksheetWrapText(bool wrap)
{
OleAutoObj objColumns = null;
oleGet(objSheet, cPropertyColumns, objColumns);
if(null != objColumns)
olePut(objColumns, cPropertyWrapText, wrap);
else
logError("Could not get the columns collection.\n");
closeIfNonNull(objColumns);
}
/* Function: setColumnWrapText(string, bool)
Purpose: sets the specified column's text wrapping property
based on the boolean.
Parameters: the column letter, whether or not to let the column wrap.
*/
void setColumnWrapText(string col, bool wrap)
{
OleAutoObj objColumn = null;
objColumn = getColumn(col);
if(null != objColumn)
{
olePut(objColumn, cPropertyWrapText, wrap);
}
closeIfNonNull(objColumn);
}
/* Function: setColumnWrapText(int, bool)
Purpose: sets whether or not to wrap text in the specified column
Parameters: the column number, whehter or not to wrap
*/
void setColumnWrapText(int col, bool wrap)
{
setColumnWrapText(intToCol(col), wrap);
}
/* Function: excel_setColumnWidth(string, real)
Purpose: sets the width of the specified Excel column.
setColumnWidth is a predefined dxl function, and
cannot be overloaded, so the funciton name is
preceded with excel_
Parameters: the column letters, the size as a floating point number
*/
void excel_setColumnWidth(string col, real cSize)
{
OleAutoObj objColumn = null;
objColumn = getColumn(col);
if(null != objColumn)
{
olePut(objColumn, cPropertyColumnWidth, cSize);
}
closeIfNonNull(objColumn);
}
/* Function: excel_setColumnWidth(int, real)
Purpose: sets the width of the specified column
Parameters: the column number, the size as a floating point number
*/
void excel_setColumnWidth(int col, real cSize)
{
excel_setColumnWidth(intToCol(col), cSize);
}
/* Function: excel_setColumnWidth(real)
Purpose: sets the width of the current column
Parameters: the size as a floating point number
*/
void excel_setColumnWidth(real cSize)
{
olePut(objSel, cPropertyColumnWidth, cSize);
}
/* Function: activateSheet(string)
Purpose: activates the sheet having the specified name
Parameters: the sheet name
*/
void activateSheet(string sheetName)
{
OleAutoObj objSheets = null;
oleGet(objWorkbook, cPropertySheets, objSheets);
if(null != objSheets)
{
clear(objArgBlock);
put(objArgBlock, sheetName);
oleGet(objSheets, cMethodItem, objArgBlock, objSheet);
if(null != objSheet)
{
oleMethod(objSheet, cMethodActivate);
if(!find(sheetList, sheetName, objCurrentSheet))
{
logError("Could not retrieve a DxlObject representing the sheet named " sheetName);
return;
}
}
else
logError("Could not get the sheet " sheetName " from the sheets collection.");
}
else
logError("Could not get the sheets collection from the workbook.");
closeIfNonNull(objSheets);
}
/* Function: activateSheet(int)
Purpose: activates the sheet having the specified number
Parameters: the sheet number
*/
void activateSheet(int sheetNum)
{
OleAutoObj objSheets = null;
string sheetName = null;
oleGet(objWorkbook, cPropertySheets, objSheets);
if(null != objSheets)
{
clear(objArgBlock);
put(objArgBlock, sheetNum);
oleGet(objSheets, cMethodItem, objArgBlock, objSheet);
if(null != objSheet)
{
oleMethod(objSheet, cMethodActivate);
oleGet(objSheet, cPropertyName, sheetName);
if(!find(sheetList, sheetName, objCurrentSheet))
{
logError("Could not retrieve a sheet from the sheet list named " sheetName " with index " sheetNum "");
return;
}
}
else
logError("Could not get sheet " sheetNum " from the sheets collection.");
}
else
logError("Could not get the sheets collection from the workbook.");
closeIfNonNull(objSheets);
}
/* Function: setSheetName(int, string)
Purpose: sets the name of the sheet having the specified sheet number
Parameters: the sheet number, the sheet name
*/
void setSheetName(int sheetNumber, string sheetName)
{
OleAutoObj objSheets = null;
string oldName = null;
DxlObject dxlObjSheet = null;
oleGet(objWorkbook, cPropertySheets, objSheets);
if(null != objSheets)
{
clear(objArgBlock);
put(objArgBlock, sheetNumber);
oleGet(objSheets, cMethodItem, objArgBlock, objSheet);
if(null != objSheet)
{
oleGet(objSheet, cPropertyName, oldName);
olePut(objSheet, cPropertyName, sheetName);
if(find(sheetList, oldName, dxlObjSheet))
{
dxlObjSheet-> s_sheetName = sheetName;
delete(sheetList, oldName);
put(sheetList, sheetName, dxlObjSheet);
}
}
else
logError("Could not get the sheet number " sheetNumber " from the sheets collection for setSheetName(int, string)");
}
else
logError("Could not get the sheets collection from the workbook for setSheetName(int, string)");
closeIfNonNull(objSheets);
}
/* Function: setSheetName(string, string)
Purpose: changes the name of the sheet having the specified name
Parameters: the old sheet name, the new sheet name
*/
void setSheetName(string oldName, string newName)
{
OleAutoObj objSheets = null;
DxlObject dxlObjSheet = null;
string sheet = null;
oleGet(objWorkbook, cPropertySheets, objSheets);
if(null != objSheets)
{
clear(objArgBlock);
sheet = "sheet" oldName "";
put(objArgBlock, sheet);
oleGet(objSheets, cMethodItem, objArgBlock, objSheet);
if(null != objSheet)
{
olePut(objSheet, cPropertyName, newName);
if(find(sheetList, oldName, dxlObjSheet))
{
delete(sheetList, oldName);
put(sheetList, newName, dxlObjSheet);
}
}
else
logError("Could not get the sheet named " oldName " for changeSheetName(string, string)");
}
else
logError("Could not get the sheets collection for changeSheetName(string, string)");
closeIfNonNull(objSheets);
}
/* Function: boldSelection()
Purpose: bolds the cell that is currently selected
*/
void boldSelection()
{
OleAutoObj objFont = null;
if(null != objSel)
{
oleGet(objSel, cPropertyFont, objFont);
if(null != objFont)
{
olePut(objFont, cPropertyBold, true);
}
}
closeIfNonNull(objFont);
}
/* Function: setMaxCols(string, int)
Purpose: sets the maximum number of columns that may be written for a
row before the writing needs to go to the next row for the given
sheet name using the given maximum
Parameters: the sheet name, the maximum number of columns
*/
void setMaxCols(string sheetName, int maxCols)
{
if(null == sheetList)
return;
if(find(sheetList, sheetName, objCurrentSheet))
objCurrentSheet-> i_maxCols = maxCols;
}
/* Function: writeToExcel(string)
Puprose: writes the given data to the Excel document using the
currently active sheet
Parameters: the data to write
*/
void writeToExcel(string sData)
{
int num = 0;
if(null == sData)
sData = " ";
if(null == objCurrentSheet)
{
logError("Could not write to the sheet because WriteToExcel does not have a handle on it.");
return;
}
setCell((int objCurrentSheet->i_rowNum), (int objCurrentSheet->i_colNum), sData);
num = (int objCurrentSheet->i_colNum);//Set num equal to the current value of colNum
num++;//Increments the column number by one
objCurrentSheet->i_colNum = num;//Sets the colNum to be the new value of num
if((int objCurrentSheet->i_maxCols) < (int objCurrentSheet->i_colNum))//Tests to see if the value of colNum has reached the maximum number of columns
{
objCurrentSheet->i_colNum = 1;//If so, the column number is reset to one to begin a new row
num = (int objCurrentSheet->i_rowNum);//The row number is also incremented
num++;
objCurrentSheet->i_rowNum = num;
}
}
/* Function: writeToExcel(string, string)
Purpose: writes the data passed as the second parameter to the Excel
document on the sheet that has the name passed as parameter one
Parameters: the sheet name, the data to write
*/
void writeToExcel(string sheetName, string sData)
{
DxlObject objTemp = null;
int num = 0;
if(null == sData)
sData = " ";
if(null != sheetList)
{
if(find(sheetList, sheetName, objTemp))//Checks to see if the passed-in sheet name is in the sheet list
{
activateSheet(sheetName);
//Passes in the current value for rowNum and colNum, and the data to put in the cell.
setCell((int objTemp->i_rowNum), (int objTemp->i_colNum), sData);
num = (int objTemp->i_colNum);//Set num equal to the current value of colNum
num++;//Increments the column number by one
objTemp->i_colNum = num;//Sets the colNum to be the new value of num
if((int objTemp->i_maxCols) < (int objTemp->i_colNum))//Tests to see if the value of colNum has reached the maximum number of columns
{
objTemp->i_colNum = 1;//If so, the column number is reset to one to begin a new row
num = (int objTemp->i_rowNum);//The row number is also incremented
num++;
objTemp->i_rowNum = num;
}
}
}
}
/* Function: writeToExcel(int, string)
Purpose: writes the given data to the Excel document on the given sheet number
Parameters: the sheet number, the data to write
*/
void writeToExcel(int sheetNum, string sData)
{
DxlObject objTemp = null;
int num = 0;
activateSheet(sheetNum);
writeToExcel(sData);
}
|
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module ManojBharat - Wed Apr 29 19:25:39 EDT 2015 yes. your understanding is correct. But I want to generate for multiple modules at one go. Change those logMessage and logError functions to print(string) instead, since that function is not defined here. Add #include<Ole.inc> to the includes near the top there
Also, add the following function to the top of the file:
/* Function: incrementIntValue(DxlObject, string)
Purpose: increments the value of the given member of the given
DxlObject assuming that the member described by the
given member name is of type int.
Parameters: the DxlObject containing the integer,
the name of the member of the DxlObject that should be incrmented
*/
void incrementIntValue(DxlObject dxlObj, string memberName)
{
int i = 0;
if(null == dxlObj)
return;
if(null == memberName)
return;
i = (int dxlObj->memberName);
i++;
dxlObj->memberName = i;
}
Now, you need to write yourself a program that loops through all the Modules you need it to go through. Create yourself a Skip list or string array of Attributes you want to print from each. Initialize MS Excel using the functions defined in WriteToExcel. Loop through each Object in each Module and retrieve the values you need. Write them to the necessary sheets using the functions defined in WriteToExcel. Add new sheets for each Module as necessary. Name them using the functions defined in WriteToExcel. Let me know if you need anything else. |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module woodpryan - Thu Apr 30 11:35:09 EDT 2015 Change those logMessage and logError functions to print(string) instead, since that function is not defined here. Add #include<Ole.inc> to the includes near the top there
Also, add the following function to the top of the file:
/* Function: incrementIntValue(DxlObject, string)
Purpose: increments the value of the given member of the given
DxlObject assuming that the member described by the
given member name is of type int.
Parameters: the DxlObject containing the integer,
the name of the member of the DxlObject that should be incrmented
*/
void incrementIntValue(DxlObject dxlObj, string memberName)
{
int i = 0;
if(null == dxlObj)
return;
if(null == memberName)
return;
i = (int dxlObj->memberName);
i++;
dxlObj->memberName = i;
}
Now, you need to write yourself a program that loops through all the Modules you need it to go through. Create yourself a Skip list or string array of Attributes you want to print from each. Initialize MS Excel using the functions defined in WriteToExcel. Loop through each Object in each Module and retrieve the values you need. Write them to the necessary sheets using the functions defined in WriteToExcel. Add new sheets for each Module as necessary. Name them using the functions defined in WriteToExcel. Let me know if you need anything else. Thanks for the reply. After looking at the code I realized that this code is more on excel implementation but my real doubt or question is DOORS side. I have written a code which opens up the DOORS tool and go to a particular module of the project and export that module in excel. Now what I want is suppose there are 10 modules in a project and I have to export all the modules to excel, excel may be a single file with multiple sheets or it may be different excel files at all. Below is the dxl file written by me.
//export.dxl
bool confirm(string s)
{
print "Confirmed: " s "\n"; return true
}
void ack (string s)
{
print "Acknowledge: " s "\n"
}
// void acknowledge (string s) {print "Acknowledge: " s "\n" }
void infobox (string s)
{
print "Info: " s "\n"
}
void info (string s)
{
print "Info: " s "\n"
}
DB theDiag = null
//Module m = null
// Now override block and show, to only do realize
void show (DB x)
{
realize x; theDiag = x
}
void block (DB x)
{
realize x; theDiag = x
}
if (null current Module)
{
print "You need to have a current Module set for the export."
halt
}
string replace(string sSource, string sSearch, string sReplace)
{
int iLen = length sSource
if (iLen == 0) return ""
int iLenSearch = length(sSearch)
if (iLenSearch == 0)
{
print "search string must not be empty"
return ""
}
// read the first char for latter comparison -> speed optimization
char firstChar = sSearch[0]
Buffer s = create()
int pos = 0, d1,d2;
int i
while (pos < iLen) {
char ch = sSource[pos];
bool found = true
if (ch != firstChar) {pos ++; s+= ch; continue}
for (i = 1; i < iLenSearch; i++)
if (sSource[pos+i] != sSearch[i]) { found = false; break }
if (!found) {pos++; s+= ch; continue}
s += sReplace
pos += iLenSearch
}
string result = stringOf s
delete s
return result
}
// we need braces, since -D will be executed at top level and we will get name
// clashes for variable defined in word.dxl and the other includes of it.
{
// now include the word.dxl -> this will pop up the dialog, but not halt execution
// due to the overrides above
#include <standard/export/office/excel.dxl>
doExcel theDiag
if (!null theDiag) destroy theDiag
OleAutoObj oleWorkbooks = null;
OleAutoObj oleExcel = null;
OleAutoObj oleWorkbook = null;
OleAutoArgs autoArgs = create;
oleExcel = oleGetAutoObject("Excel.Application");
bool opened = false;
oleGet(oleExcel,"Workbooks", oleWorkbooks);
// compare each open workbook
int count = 1;
oleGet(oleWorkbooks,"Count", count);
string workbookname = "BDP";
//string sPath = replace(fPath, "\\", "/");
clear(autoArgs);
put(autoArgs, count);
oleGet(oleWorkbooks,"Item", autoArgs, oleWorkbook);
oleGet(oleWorkbook, "Name", workbookname);
clear(autoArgs);
put(autoArgs, "C:\\DOORS_testing\\BDP.xlsx");
oleMethod(oleWorkbook, "SaveAs", autoArgs)
oleMethod(oleWorkbook,"Close",autoArgs);
oleCloseAutoObject(oleExcel);
oleCloseAutoObject(oleWorkbooks);
oleCloseAutoObject(oleWorkbook);
//close DOORS
exit_
}
the above code I am invoking through batch file (doors_export.bat) below is the batch file
@echo off
if "%~1"=="" (
echo You need to start this script with a DOORS Module
goto :real_end
)
"C:\Program Files (x86)\IBM\Rational\DOORS\9.3\\bin\DOORS.exe" -u mg47128 -password mg47128 -f "%TEMP%" -D "current = read(\""/ASD_NEW/Software/Subsystems/Project/BDP/BDP SRS\"", true);#include <export.dxl>;"
:real_end
So now This code is working fine for one module that also hard coded in batch file and dxl file. I want either save all the modules with different file names which is module name itself or it store in one single excel file. In the above case, BDP.xlsx will be the output file. But here also I need help to get modules name dynamically, which is hard coded now (BDP.xlsx). I hope this will explain more about my question!!! |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module I would recommend you think outside that box of calling the doExcel function defined in Excel.dxl, and write your own function that does that export. You know which Modules you want this thing to happen for. If they're all in a single folder, you can loop through the folder to get them. It's just a matter of taking the functionality you want and copying it, then looping over the Modules to call that bit of functionality for each of them. The Excel.dxl file does things FOR you in a Non-generic way. You want something more reusable.
Write a function that initializes the WriteToExcel.inc stuff. Write another function that loops over the Modules you need to export, and simply write out the information you need for each of them using the WriteToExcel generic functions provided. Do you really need the Excel.dxl GUI? Do you not make the same old selections every time? In other words, there are some things about the predefined functionality in Excel.dxl that are too specific to exporting one Module, and your task requires a more generic Excel interface. Without modifying the code in Excel.dxl or including the more generic version I've given you, there is no way to complete your task. |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module woodpryan - Thu Apr 30 14:23:51 EDT 2015 I would recommend you think outside that box of calling the doExcel function defined in Excel.dxl, and write your own function that does that export. You know which Modules you want this thing to happen for. If they're all in a single folder, you can loop through the folder to get them. It's just a matter of taking the functionality you want and copying it, then looping over the Modules to call that bit of functionality for each of them. The Excel.dxl file does things FOR you in a Non-generic way. You want something more reusable.
Write a function that initializes the WriteToExcel.inc stuff. Write another function that loops over the Modules you need to export, and simply write out the information you need for each of them using the WriteToExcel generic functions provided. Do you really need the Excel.dxl GUI? Do you not make the same old selections every time? In other words, there are some things about the predefined functionality in Excel.dxl that are too specific to exporting one Module, and your task requires a more generic Excel interface. Without modifying the code in Excel.dxl or including the more generic version I've given you, there is no way to complete your task. Thanks for the help. I think I need to go into deeper to understand dxl as I am new to this language. |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module woodpryan - Thu Apr 30 14:23:51 EDT 2015 I would recommend you think outside that box of calling the doExcel function defined in Excel.dxl, and write your own function that does that export. You know which Modules you want this thing to happen for. If they're all in a single folder, you can loop through the folder to get them. It's just a matter of taking the functionality you want and copying it, then looping over the Modules to call that bit of functionality for each of them. The Excel.dxl file does things FOR you in a Non-generic way. You want something more reusable.
Write a function that initializes the WriteToExcel.inc stuff. Write another function that loops over the Modules you need to export, and simply write out the information you need for each of them using the WriteToExcel generic functions provided. Do you really need the Excel.dxl GUI? Do you not make the same old selections every time? In other words, there are some things about the predefined functionality in Excel.dxl that are too specific to exporting one Module, and your task requires a more generic Excel interface. Without modifying the code in Excel.dxl or including the more generic version I've given you, there is no way to complete your task. I was going through the DXL Help document in DOORS, there I saw below lines of text: """"""""""""""""""""""""""""""""""""""""""""" sortDiscussionsDeclaration
void sortDiscussions({Module
Operation
Sorts the discussions list associated with the specified item according to the given If the discussion list for the specified item has not been loaded from the database, this perm will cause it to be loaded.
The """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" What I understood from last line is that Folders and Projects can't be parsed through and in that case is it possible to get the attributes values for multiple modules? Is my understanding correct? |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module ManojBharat - Mon May 04 10:40:48 EDT 2015 I was going through the DXL Help document in DOORS, there I saw below lines of text: """"""""""""""""""""""""""""""""""""""""""""" sortDiscussionsDeclaration
void sortDiscussions({Module
Operation
Sorts the discussions list associated with the specified item according to the given If the discussion list for the specified item has not been loaded from the database, this perm will cause it to be loaded.
The """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" What I understood from last line is that Folders and Projects can't be parsed through and in that case is it possible to get the attributes values for multiple modules? Is my understanding correct? You don't even need to worry about "Discussions," I don't think. What you need are the following functions:
for Item in Project do Operation: Loops through all Items in a Project. Works recursively, looping through every item in the Project's tree. You need this because the for Module in Project loop only works for Modules that are open at the time of execution, and you need to see everything. Test it for type(Item) == "Formal" (a Formal Module). To get the Module call Module mod = read(fullName(Item), false) This function will open the Item as a Module in read mode, invisibly. Next: for AttrDef in Module do Operation: loops through all the Attribute definitions in the Module to retrieve each Attribute defined. Includes all System Attributes, User defined Attributes, and even LayoutDXL Attributes.
Finally, for Object in all Module do Operation: Loops through every Object of the Module, including those that are deleted or not visible in the default view. For each of these Objects, you need the loop through a list of strings representing the names of the Attributes, which you should be retrieving during your for AttrDef in Module loop. Use those names to retrieve the values of each Attribute from each Object, then export the value to MS Excel using the functions provided in WriteToExcel above.
That should be about all you need, my friend. Just slap all that together, and I think you've got the program you're looking for. Let me know if you have any problems. In WriteToExcel you will find numerous instances of a function called "logError" or "logMessage". You can either write your own version of these functions, which write to a log file, or you can write a version of these functions that just takes the string and prints it, or you can just change the calls to these functions to calls to the print(string) function. |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module Hello Guys, Can some support as I also need to generate excel report from the doors modules. I also need all doors modules in one excel sheet. Please looking for the positive response.
Regards, Jayi |
Re: How to export multiple modules from DOORS at once or generate a list of parameters of one particular column in each module JayiConti - Wed Jul 26 07:22:25 EDT 2017 Hello Guys, Can some support as I also need to generate excel report from the doors modules. I also need all doors modules in one excel sheet. Please looking for the positive response.
Regards, Jayi First off all - do not pull those old threads. Instead open a new one and reference the old one. the reason is simple: People are less likely to respond if a thread already has 10 answers and you cannot mark the thread as answered once you get a good answer. There are several posts on automating exports on the forum. Also there are a couple of tools around (Advanced Excel export). You need to come up with a specific problem for someone to help you. Nobody is going to do the work for you. So please open another post with a specific problem, that can be answered instead of a use case description. Regards, Mathias |