// Export module using automation to Excel 97 // Licensed Materials - Property of IBM - some unique copyrights (i.e., the ability // to copy, modify, distribute) may be licensed in certain circumstances // (e.g., sample/template code intended to be used by customers to build upon and // distribute as their own products). // // DOORS - %full_filespec: excel.dxl~39:dxl:ERS#1 % %date_created: Wed Jun 19 12:39:35 2013 % // // (c) Copyright IBM Corporation 1993, 2011. All Rights Reserved. // // U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted // by GSA ADP Schedule Contract with IBM Corp. //-------------------------------------------------------------------------------------------- // Changes on original Excel Export made // Coder: Tobias Mehrl // Date: 2015-09-07 //-------------------------------------------------------------------------------------------- /* Export current DOORS module to Excel via automation. Exports all visible columns Object == Row Column == Column Pictures and OLE Object are not exported */ pragma runLim,0 #include #include checkPlatform (NLS_("Microsoft Excel")) bool ifFolderExport = false bool isExcelAlreadyStarted = false Object o = current Folder f = current Item i Module currentModule = null string myMainView View myView const string mainChoices[] = {(NLS_("Ignore")), AHeading, AShortText, ALongText, (NLS_("Object Heading And Text")), (NLS_("CompleteView"))} const int mainIgnore = 0 const int mainHeading = 1 const int mainShort = 2 const int mainLong = 3 const int mainHeadingLong = 4 const int CompleteView = 5 const int NO_HEADING = 0 const int HEADING_ONLY = 1 const int BOTH_HEADING_AND_TEXT = 2 const string mainViews[] = {(NLS_("EEM_Standard"))} const int mainIntegrTest_Export = 0 //-------------------------------------------------------------- OleAutoObj objExcel = null OleAutoObj objWorkbooks = null OleAutoObj objWorkbook = null OleAutoObj objSheet = null OleAutoObj objCell = null OleAutoArgs args = null OleAutoObj objCharacterRange = null OleAutoObj objFont = null //-------------------------------------------------------------- DB excelBox = null DBE mainChoice, mainView, titleToggle, preserveRichTextFormattingToggle Trigger excelTrigger Module m = current bool includeColumnTitles = true, preserveRichTextFormatting = false int noObjs = 0 void initProgress(DB forWin, Module m) { //Debug print "H \n" Object o noObjs = 0 for o in m do { noObjs++ } progressStart(forWin, LS_("String_Export_Progress",NLSTEMP_("Export Progress")), LS_("String_Exporting_1",NLSTEMP_("Exporting ")), noObjs) //Debug print "HH \n" } void stepProgress(int objNo) { //Debug print "M \n" progressStep objNo progressMessage (dxlStrformat(LS_("String_Exporting_s_of_s",NLSTEMP_("Exporting %s of %s")), objNo (NLS_("")), noObjs (NLS_(""))) ) //Debug print "MM \n" } void preChecks() { //Debug print "K \n" //Display a message when unable to read the object /*if(null(o)) { ack getExtMsg("String_Cannot_read_the_object", NLSTEMP_("Cannot read the object")) halt }*/ //If it is a module opened if(!null(o)) { string attributeName = o.(reserved AMainColumnAttribute) if(!null attributeName) { if(!canRead o.attributeName) { ack dxlStrformat(getExtMsg("String_Cannot_read_s",NLSTEMP_("The attribute, %s, cannot be accessed.")), ALongText) halt } } else { if (!canRead o.AHeading) { ack dxlStrformat(getExtMsg("String_Cannot_read_s",NLSTEMP_("The attribute, %s, cannot be accessed.")), AHeading) halt } if (!canRead o.AShortText) { ack dxlStrformat(getExtMsg("String_Cannot_read_s",NLSTEMP_("The attribute, %s, cannot be accessed.")), AShortText) halt } if (!canRead o.ALongText) { ack dxlStrformat(getExtMsg("String_Cannot_read_s",NLSTEMP_("The attribute, %s, cannot be accessed.")), ALongText) halt } } } else { //Debug //folder loop /*Item i Module currentModule for i in f do { currentModule = read(fullName(i), false, true) //Debug print(name(currentModule)) //call function }*/ } //Debug print "KK \n" } bool excelInit(Module currentModule) { //Debug print "E \n" // Connect to excel only, if it is a module export or the first module from a folder export if(isExcelAlreadyStarted == false) { objExcel = connectToApp(cObjExcelApplication, (NLS_("Excel"))) } if (null objExcel) { return false } // makeVisible objExcel // get workbooks collection checkRes(oleGet(objExcel, cPropertyWorkbooks, objWorkbooks)) if (null objWorkbooks) { ack getExtMsg("String_Unable_to_get_workbooks_collection",NLSTEMP_("The export failed because the workbooks collection was not retrieved.")) return false } //oleCloseAutoObject(objExcel) //oleCloseAutoObject(objWorkbooks) // add one Workbook if(isExcelAlreadyStarted == false) { checkRes(oleMethod(objWorkbooks, cMethodAdd)) //oleCloseAutoObject(objWorkbooks) } // get active workbook checkRes(oleGet(objExcel, cPropertyActiveWorkbook, objWorkbook)) if (null objWorkbook) { ack getExtMsg("String_Unable_to_get_active_workbook",NLSTEMP_("The export failed because the active workbook cannot be retrieved.")) return false } //oleCloseAutoObject(objExcel) //oleCloseAutoObject(objWorkbook) // get active sheet checkRes(oleGet(objWorkbook, "Sheets", objSheet)) if (null objSheet) { ack getExtMsg("String_Unable_to_get_active_sheet",NLSTEMP_("The export failed because the client cannot retrieve the active sheet.")) return false } //oleCloseAutoObject(objWorkbook) //oleCloseAutoObject(objSheet) // add new sheet checkRes(oleMethod(objSheet, "Add")) if (null objSheet) { ack getExtMsg("String_Unable_to_add_a_new_sheet",NLSTEMP_("The export failed because the client cannot retrieve a new sheet.")) return false } //oleCloseAutoObject(objSheet) // get active sheet checkRes(oleGet(objWorkbook, cPropertyActiveSheet, objSheet)) if (null objSheet) { ack getExtMsg("String_Unable_to_get_active_sheet",NLSTEMP_("The export failed because the client cannot retrieve the active sheet.")) return false } //oleCloseAutoObject(objWorkbook) //oleCloseAutoObject(objSheet) // Rename activated, current Worksheet string sheetName = name(currentModule) checkRes(olePut(objSheet, cPropertyName, sheetName)) //oleCloseAutoObject(objSheet) // set "isExcelAlreadyStarted"-Flag to true, if first module is exported isExcelAlreadyStarted = true return true //Debug print "EE \n" } string intToCol(int i) { //Debug print "I \n" string s = (NLS_("")) if ((i>=1) && (i<=256)) { int d1 = (i-1) / 26 int d2 = (i-1) % 26 if (d1 > 0) { s = charOf( d1-1 + intOf('A')) (NLS_("")) } s = s charOf( d2 + intOf('A')) (NLS_("")) } else { if (i>256) { ack LS_("String_Too_many_columns",NLSTEMP_("Too many columns")) } else { ack dxlStrformat(getExtMsg("String_Invalid_column_reference_s",NLSTEMP_("Invalid column reference :%s")), i (NLS_(""))) } halt } //Debug print "II \n" return (s) } Regexp dateCheck = regexp (NLS_("^([0-9]+-)+[0-9]+$")) // Gets the font object associated with the passed-in range and sets global variable objFont with it. // The caller MUST delete the objFont using closeIfNonNull() after use. void getObjFont(int startOfRange, int endOfRange) { //Debug print "F \n" OleAutoArgs rtfMacroArgs = create clear(rtfMacroArgs) put(rtfMacroArgs, startOfRange) put(rtfMacroArgs, endOfRange) checkRes(oleGet(objCell, cMethodCharacters, rtfMacroArgs, objCharacterRange)) checkRes(oleGet(objCharacterRange, cPropertyFont, objFont)) closeIfNonNull objCharacterRange delete rtfMacroArgs //Debug print "FF \n" } // Applies RTF formatting to the (plain) text already exported to excel sheet. The passed-in RTF should be // the rich text version of the plain text already exportet. // We apply following RTF settings to the exported text from the passed-in rtfString: // 1). Bold // 2). Italiv // 3). Strikethrough // 4). Superscript // 5). Subscript // 6). Underline // If headingInfo is either HEADING_ONLY or BOTH_HEADING_AND_TEXT, we apply bold setting to the complete cell // iff the heading text in passed-in RTF string does not have bold applied at all. void applyRTFFormattingToExportedText(string rtfString, int headingInfo) { //Debug print "A \n" if(rtfString == (NLS_(""))) { return } RichText rt int endCharInThisChunk = 0 bool previousChunkHadNewline = false int startCharForHeading = 1, endCharForHeading = -1 bool pastHeading = false // applies when the passed-in RTF string contains heading. Tells whether we are past the last // heading character in the loop below (when the RTF string contains both object heading and text). bool headingAlreadyHasBold = false if(headingInfo != HEADING_ONLY && headingInfo != BOTH_HEADING_AND_TEXT) { pastHeading = true } for rt in rtfString do { endCharInThisChunk += rt.charCount if(previousChunkHadNewline) { if(headingInfo == BOTH_HEADING_AND_TEXT && !pastHeading) { pastHeading = true endCharForHeading = endCharInThisChunk - rt.charCount } // increase the count by 1 as the chunk previous to this was followed by a newline character // which was not taken into account endCharInThisChunk++ // reset previousChunkHadNewline = false } // get OLE auto object for this chunk only if there's some non-default formatting since // getting OLE auto object is expensive and consumes both memory and time if(rt.bold || rt.italic || rt.strikethru || rt.superscript || rt.subscript || rt.underline) { getObjFont(endCharInThisChunk - rt.charCount + 1, rt.charCount) if(rt.bold) { if(!pastHeading && (headingInfo == HEADING_ONLY || headingInfo == BOTH_HEADING_AND_TEXT)) { headingAlreadyHasBold = true } } // Apply font style if(rt.bold && rt.italic) { checkRes(olePut(objFont, cPropertyFontStyle, cParamBoldItalicFontStyleOption)) } else if(rt.bold) { checkRes(olePut(objFont, cPropertyFontStyle, cParamBoldOnlyFontStyleOption)) } else if(rt.italic) { checkRes(olePut(objFont, cPropertyFontStyle, cParamItalicOnlyFontStyleOption)) } // Apply strikethru if(rt.strikethru) { checkRes(olePut(objFont, cPropertyStrikethru, true)) } // Apply superscript if(rt.superscript) { checkRes(olePut(objFont, cPropertySuperscript, true)) } // Apply subscript if(rt.subscript) { checkRes(olePut(objFont, cPropertySubscript, true)) } // Apply underline if(rt.underline) { checkRes(olePut(objFont, cPropertyUnderline, xlUnderlineStyleSingle)) } closeIfNonNull objFont } if(rt.newline) { previousChunkHadNewline = true } if(headingInfo == HEADING_ONLY && rt.last) { endCharForHeading = endCharInThisChunk } } // now apply bold setting to heading iff the RTF string has heading AND it does not already have bold setting applied if((headingInfo == HEADING_ONLY || headingInfo == BOTH_HEADING_AND_TEXT) && !headingAlreadyHasBold && endCharForHeading > 0) { getObjFont(startCharForHeading, endCharForHeading) checkRes(olePut(objFont, cParamBoldOnlyFontStyleOption, true)) closeIfNonNull objFont } //Debug print "AA \n" } /*applyRTFFormattingToExportedText*/ bool checkViewAvailability(string mMV, View mV, Module cM) { bool vWF = null //vWF = 'viewWasFound' bool viewIsLoaded = null //Debug print "Begin view-loop \n" string v for v in views(cM) do { if(mMV == v) //mMV = 'myMainView' { setDefaultViewForModule(cM, mMV) load(view(item(fullName(cM)), mMV)) //Loads view depending on GUI selection. Note: View can only be loaded, if module is opened in GUI! vWF = true //Debug print "viewWasFound: " vWF "\n" print "myMainView: " mMV "\n" break } else { setDefaultViewForModule(cM, getDefaultViewForModule(cM)) //The view could only be set in the module, if the module is already opened in the GUI vWF = false //Debug print "viewWasFound: " vWF "\n" } } return vWF } void setCell(int row, int col, string s, string rtfString, int headingInfo) { //Debug print "L \n" print "setCell, #col: " col "\n" //If object not null -> close if(!null(objCell)) { closeIfNonNull objCell //objCell = null } clear(args) put(args, (intToCol col) row (NLS_(""))) checkRes(oleGet(objSheet, cMethodRange, args, objCell)) if (null objCell) { ack getExtMsg("String_Unable_to_get_cell_object",NLSTEMP_("Unable to get cell object")) halt } // 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. if( s[0:0] == (NLS_("=")) || s[0:0] == (NLS_("+")) || s[0:0] == (NLS_("-")) || s[0:0] == (NLS_("@")) || dateCheck s ) { s = (NLS_("'")) s } // first set the cell with plain text checkRes(olePut(objCell, cPropertyValue, s)) //In this line string in string s will be written in // now apply the RTF formatting in case the passed-in rtfString is non-NULL AND the user // has chosen to export the rich text formatting. if(rtfString != (NLS_("")) && preserveRichTextFormatting) { applyRTFFormattingToExportedText(rtfString, headingInfo) } //Debug print "LL \n" } void headingLong(Object o, bool bRTF, Buffer &buf, int &headingInfo) { //Debug print "G \n" Buffer headingBuf = create, textBuf = create fullAttributeValue_(o, AHeading, bRTF, headingBuf, false) fullAttributeValue_(o, ALongText, bRTF, textBuf, false) if (length(headingBuf) <= 0) { buf = tempStringOf textBuf delete headingBuf delete textBuf headingInfo = NO_HEADING //Debug print "GG \n" return } if (length(textBuf) <= 0) { buf = tempStringOf headingBuf delete headingBuf delete textBuf headingInfo = HEADING_ONLY //Debug print "GG \n" return } buf = tempStringOf(headingBuf) (NLS_("\n")) tempStringOf(textBuf) //Debug print "Buffer: " buf "\n" headingInfo = BOTH_HEADING_AND_TEXT delete headingBuf delete textBuf //Debug print "GG \n" } void completeView(Object o, bool bRTF, Buffer &buf, int &headingInfo) { Buffer headingBuf = create, textBuf = create fullAttributeValue_(o, "Änderungsstatus", bRTF, textBuf, false) if(length(headingBuf) <= 0) { buf = tempStringOf textBuf delete headingBuf delete textBuf headingInfo = NO_HEADING return } if(length(textBuf) <= 0) { buf = tempStringOf headingBuf delete headingBuf delete textBuf headingInfo = HEADING_ONLY return } buf = tempStringOf(headingBuf) (NLS_("\n")) tempStringOf(textBuf) headingInfo = BOTH_HEADING_AND_TEXT delete headingBuf delete textBuf } Module requestHandleOfCurrentModule(Item itm) { return read(fullName(itm), true, true) //the 2nd parameter won't open the module in the GUI (false) or will it open (true) } void getNumColumns(Module mod, string mMV) { //Debug print "Get Columns" "\n" load(view(item(fullName(mod)), mMV)) //Loads view depending on GUI selection. Note: view can only be loaded, if module is opened GUI! Column c = null int count = 0 if(null == mod) { print "Count = " count "\n" } for c in mod do { count++ } print "Count = " count "\n" } void doExcel(DB xx) { //Debug print "D \n" //Buffer rtfStringBuffer, plainTextBuffer //rtfStringBuffer = create //plainTextBuffer = create //If only one Module should be exported if(ifFolderExport == false) { Object o Column c string s int doMain int row = 0 int col //Sets the used view to the view which was choosed in the GUI myMainView = get mainView myView = view(myMainView) //Debug print "myMain View: " myMainView "\n" setDefaultViewForModule(m, myMainView) if(checkViewAvailability(myMainView, myView, current)) { //If Excel wasn't started until now if(!excelInit(current)) { delete args delete excelTrigger return } doMain = get mainChoice includeColumnTitles = get titleToggle preserveRichTextFormatting = get preserveRichTextFormattingToggle if (includeColumnTitles) { col = 0 row++ for c in m do { if ((main c) && (doMain == mainIgnore)) continue col++ s = title c if (s != (NLS_(""))) { setCell(row, col, s, null, NO_HEADING) } } } initProgress(excelBox, m) initNotDisplayedOpenModules() for o in m do { if (DisplayMemoryWarning()) { break } col = 0 row ++ int rowExcludingTitle = 0 if (progressCancelled) break if (includeColumnTitles) { rowExcludingTitle = row - 1 stepProgress rowExcludingTitle } else { stepProgress row } Buffer rtfStringBuffer, plainTextBuffer for c in m do { rtfStringBuffer = create plainTextBuffer = create col++ int headingInfo = NO_HEADING if (main c) { //Check if the object is read locked if (doMain == mainIgnore || !canRead o) { col-- continue } string attributeName = getDisplayedAttributeName(o) if(null attributeName) { if (doMain == mainHeading) { if(preserveRichTextFormatting) { rtfStringBuffer = richText o.AHeading } fullAttributeValue_(o, AHeading, false, plainTextBuffer, false) headingInfo = HEADING_ONLY } if (doMain == mainShort) { if(preserveRichTextFormatting) { rtfStringBuffer = richText o.AShortText } plainTextBuffer = o.AShortText } if (doMain == mainLong) { if(preserveRichTextFormatting) { rtfStringBuffer = richText o.ALongText } fullAttributeValue_(o,ALongText,false, plainTextBuffer, false) } if (doMain == mainHeadingLong) { if(preserveRichTextFormatting) { //Debug print "headingLong Module \n" headingLong(o, true, rtfStringBuffer, headingInfo) } headingLong(o, false, plainTextBuffer, headingInfo) } } // if(null attributeName) else { //Map the main column attribute to the Object text amd/or //Object heading and text if (doMain == mainLong || doMain == mainHeadingLong) { if(!hasCopyableTableAttribute(o, attributeName)) { continue } // check that the attribute is a string or text attribute AttrDef ad = find(module o, attributeName) if(preserveRichTextFormatting && !null ad && (ad.typeName == (NLS_("String")) || ad.typeName == (NLS_("Text")))) { rtfStringBuffer = richText o.attributeName } plainTextBuffer = o.attributeName if(attributeName == (NLS_("Object Heading"))) { headingInfo = HEADING_ONLY } } } // if(!null attributeName) } // if (main c) else { string attrDisplayedInCol = attrName c if(attrDisplayedInCol != (NLS_(""))) { // check that the attribute is a string or text attribute AttrDef ad = find(module o, attrDisplayedInCol) if(preserveRichTextFormatting && !null ad && (ad.typeName == (NLS_("String")) || ad.typeName == (NLS_("Text")))) { rtfStringBuffer = richText(c, o) } } if (null dxl(c)) { plainTextBuffer = tempStringOf(probeAttrBuffUSShortDate_(o, attrDisplayedInCol)) } else { plainTextBuffer = text(c,o) if(preserveRichTextFormatting && attrDisplayedInCol == (NLS_(""))) { rtfStringBuffer = richText(c, o) } } if(attrDisplayedInCol == (NLS_("Object Heading"))) { headingInfo = HEADING_ONLY } } // if (!main c) if (length(plainTextBuffer) > 0) { setCell(row, col, tempStringOf plainTextBuffer, tempStringOf rtfStringBuffer, headingInfo) } delete plainTextBuffer delete rtfStringBuffer } // for c in m } // for o in m closeNotDisplayedOpenedModules() progressStop closeIfNonNull objCell clear args delete args disconnectFromApp objExcel delete excelTrigger } // if(checkViewAvailability) else { //Debug print "Vorsicht! In " name(currentModule) " fehlt View " myMainView ".\n" } //Closes GUI in which is current module displayed without saving close(currentModule) } elseif(ifFolderExport == true) { //Debug print "Module output!\n" print "STOPP\n" Item i for i in f do { currentModule = requestHandleOfCurrentModule(i) //Debug print "doExcel: " name(currentModule) "\n" Object o Column c string s int doMain int row = 0 int col int count //Sets the used view to the view which was choosed in the GUI myMainView = get mainView myView = view(myMainView) //Check if view is in current module available if(checkViewAvailability(myMainView, myView, currentModule)) { print "isExcelAlreadyStarted: " isExcelAlreadyStarted "\n" if (!excelInit(currentModule)) { delete args //delete excelTrigger return } //Debug //print "viewWasFound: " viewWasFound "\n" doMain = get mainChoice includeColumnTitles = get titleToggle preserveRichTextFormatting = get preserveRichTextFormattingToggle if (includeColumnTitles) { col = 0 row++ //Debug print "TestcurrentModule: " name(currentModule)"\n" print "TestmyMainView: " myMainView "\n" //for c in m do for c in currentModule do //c is from type column!/ { if (main(c) && doMain == mainIgnore) { continue //Skip iteration only if object c is main text column AND "Ignore" is choosen in GUI } col++ s = title(c) //Stores title of column c in string s if (s != (NLS_(""))) { //Debug print "Row: " row "\n" print "Col: " col "\n" print "s: " s "\n" setCell(row, col, s, null, NO_HEADING) } } } //Debug print "#Col: " col "\n" print "s: " s "\n" //initProgress(excelBox, m) initProgress(excelBox, currentModule) initNotDisplayedOpenModules() //Debug //print "myMainView: " myMainView "\n" //for object in module do for o in currentModule do { if (DisplayMemoryWarning()) { break } col = 0 row ++ int rowExcludingTitle = 0 if (progressCancelled) break if (includeColumnTitles) { rowExcludingTitle = row - 1 stepProgress rowExcludingTitle } else { stepProgress row } Buffer rtfStringBuffer, plainTextBuffer //for column in module do for c in currentModule do //c is from type column { rtfStringBuffer = create plainTextBuffer = create col++ int headingInfo = NO_HEADING if(main(c)) { //Check if the object is read locked if (doMain == mainIgnore || !canRead o) { col-- continue } string attributeName = getDisplayedAttributeName(o) if(null attributeName) { if (doMain == mainHeading) { if(preserveRichTextFormatting) { rtfStringBuffer = richText o.AHeading } fullAttributeValue_(o,AHeading,false, plainTextBuffer, false) headingInfo = HEADING_ONLY } if (doMain == mainShort) { if(preserveRichTextFormatting) { rtfStringBuffer = richText o.AShortText } plainTextBuffer = o.AShortText } if (doMain == mainLong) { if(preserveRichTextFormatting) { rtfStringBuffer = richText o.ALongText } fullAttributeValue_(o,ALongText,false, plainTextBuffer, false) } if (doMain == mainHeadingLong) { if(preserveRichTextFormatting) { headingLong(o, true, rtfStringBuffer, headingInfo) } headingLong(o, false, plainTextBuffer, headingInfo) } if(doMain == CompleteView) { if(preserveRichTextFormatting) { headingLong(o, true, rtfStringBuffer, headingInfo) } headingLong(o, false, plainTextBuffer, headingInfo) } } // if(null attributeName) else { //Map the main column attribute to the Object text amd/or //Object heading and text if (doMain == mainLong || doMain == mainHeadingLong) { if(!hasCopyableTableAttribute(o, attributeName)) { continue } // check that the attribute is a string or text attribute AttrDef ad = find(module o, attributeName) if(preserveRichTextFormatting && !null ad && (ad.typeName == (NLS_("String")) || ad.typeName == (NLS_("Text")))) { rtfStringBuffer = richText o.attributeName } plainTextBuffer = o.attributeName if(attributeName == (NLS_("Object Heading"))) { headingInfo = HEADING_ONLY } } } // if(!null attributeName) } // if (main c) else { string attrDisplayedInCol = attrName c if(attrDisplayedInCol != (NLS_(""))) { // check that the attribute is a string or text attribute AttrDef ad = find(module o, attrDisplayedInCol) if(preserveRichTextFormatting && !null ad && (ad.typeName == (NLS_("String")) || ad.typeName == (NLS_("Text")))) { rtfStringBuffer = richText(c, o) } } if (null dxl(c)) { plainTextBuffer = tempStringOf(probeAttrBuffUSShortDate_(o, attrDisplayedInCol)) } else { plainTextBuffer = text(c,o) if(preserveRichTextFormatting && attrDisplayedInCol == (NLS_(""))) { rtfStringBuffer = richText(c, o) } } if(attrDisplayedInCol == (NLS_("Object Heading"))) { headingInfo = HEADING_ONLY } } // if (!main c) if(length(plainTextBuffer) > 0) { setCell(row, col, tempStringOf plainTextBuffer, tempStringOf rtfStringBuffer, headingInfo) } delete plainTextBuffer delete rtfStringBuffer } // for c in m } // for o in m closeNotDisplayedOpenedModules() progressStop closeIfNonNull objCell clear args //delete args //disconnectFromApp objExcel //delete excelTrigger isExcelAlreadyStarted = true } // if(checkViewAvailability) else { //Debug print "Vorsicht! In " name(currentModule) " fehlt View " myMainView ".\n" } //Closes GUI in which is current module displayed without saving close(currentModule) } //for i in f do disconnectFromApp objExcel } //elseif(ifFolderExport = true) //Debug print "DD \n" //print dateAndTime(today) } bool closeModuleTrig(Trigger t) { //Debug print "C \n" hide excelBox //Hide will closeDB??? return true //Debug print "CC \n" } void closeDB(DB db) { //Debug print "B \n" delete args delete excelTrigger //Deletes the trigger while we are executing??? hide excelBox //Debug print "BB \n" } void makeBoxForModuleExport() { //Debug print "J \n" //Don't parent to module! Parent to dbExplorer! //Use: excelBox = create(dbExplorer, "String_Export_Excel", styleCentered) excelBox = create(dbExplorer, "String_Export_Excel", styleCentered) //excelBox = centered LS_("String_Export_Excel", NLSTEMP_("Export Excel")) excelTrigger = trigger(module, close, 10, closeModuleTrig) //"Schliessen"-functionality of GUI mainChoice = choice(excelBox, LS_("String__Main_column", NLSTEMP_("'Main' column:")), mainChoices, mainIgnore, 30, false) mainView = choice(excelBox, LS_("String__Main_views", NLSTEMP_("'Main' views:")), mainViews, mainIntegrTest_Export, 30, false) titleToggle = toggle(excelBox,LS_("String_Include_column_titles", NLSTEMP_("Include column titles")), includeColumnTitles) preserveRichTextFormattingToggle = toggle(excelBox, LS_("String_Preserve_rich_text_formatting", NLSTEMP_("Preserve rich text formatting")), preserveRichTextFormatting) ok(excelBox,LS_("String_Export", NLSTEMP_("Export")), doExcel) help(excelBox, DOORSHelp, helpExportExcel) close(excelBox, true, closeDB) realize excelBox //Debug print "JJ \n" } void makeBoxForFolderExport() { //Debug print "N \n" //Do not parent to current module, use excelBox = create(dbExplorer, "String_Export_Excel", styleCentered) excelBox = create(dbExplorer, "String_Export_Excel", styleCentered) //excelBox = centered LS_("String_Export_Excel", NLSTEMP_("Export Excel")) //This for-loop is needed for excelTrigger, because trigger-function //expects a module in parameter list, but we don't have a module because //we will export modules in folder. So we have to "search" ANY module Item i for i in f do { currentModule = read(fullName(i), false, true) if(currentModule != null) //If ANY module was found, break. { break } } excelTrigger = trigger(module, close, 10, closeModuleTrig) //"Schliessen"-functionality of GUI mainChoice = choice(excelBox, LS_("String__Main_column", NLSTEMP_("'Main' column:")), mainChoices, mainIgnore, 30, false) mainView = choice(excelBox, LS_("String__Main_views", NLSTEMP_("'Main' views:")), mainViews, mainIntegrTest_Export, 30, false) titleToggle = toggle(excelBox, LS_("String_Include_column_titles", NLSTEMP_("Include column titles")), includeColumnTitles) preserveRichTextFormattingToggle = toggle(excelBox, LS_("String_Preserve_rich_text_formatting", NLSTEMP_("Preserve rich text formatting")), preserveRichTextFormatting) //Use apply here??? //ok(excelBox,LS_("String_Export", NLSTEMP_("Export")), doExcel) apply(excelBox, "Export", doExcel) //help(excelBox, DOORSHelp, helpExportExcel) close(excelBox, true, closeDB) //realize excelBox //Debug print "NN \n" } //-------------------------------------------------------------------- //Begin of "main" // check status if ((current Module) != null) //Folder opened { //Debug print "Module path \n" // check status if ((current Object) != null) { preChecks ifFolderExport = false //Debug //Module m = null //getNumColumns(current Module) args = create /*makeBoxForModuleExport() show excelBox*/ } else { ack LS_("String_There_are_no_objects_in_the_current_view",NLSTEMP_("There are no objects in the current view.")) } } else if((current Folder) != null) //Module opened { //Debug print "Folder path \n" //print dateAndTime(today) preChecks ifFolderExport = true args = create makeBoxForFolderExport() show excelBox } else { ack LS_("String_There_is_no_current_module_to_export",NLSTEMP_("There is no current module to export.")) }