IS

Hello, community!

I have writen some piece of code for creating, reading and editing *.docx files. If it is usefull for somebody, I will translate Russian comments to English. Most of the funcs are simular to ARIS standard output API's funcs.

Also, there are some additionals, like find and replace in body+headers+footers of the document.

This code is based on docx4j libraries, so for using it you have to add docx4j libraries to the ARIS server/lib category.

You have to change extansion "txt" of attachment to "js" and import it to common files on the server (Attached file is visible for registered users only). 

Hope, this is usefull.

File attachments
by Albina Schupak
Posted on Thu, 10/24/2013 - 14:58

I think so, it's always useful.

0
by Ilya Seletkov Author
Posted on Fri, 10/25/2013 - 11:01
There is example report and docx4j libraries.
https://www.dropbox.com/s/dpv1vlgppat8wjo/docx4j-2.8.1.7z
Context.setProperty(Constants.PROPERTY_SHOW_OUTPUT_FILE, true);
Context.setProperty(Constants.PROPERTY_SHOW_SUCCESS_MESSAGE, false);
//Function checks existance of object
function IsDefined(obj)
{
    if (typeof(obj)=="undefined")
        return false;
    if ((typeof(obj)=="object")&&(obj==null))
        return false;
    if (obj==undefined)
        return false; 
    return true;
}
function main()
{
    //Createing instance of wraping class CWordShell
    var oWord = new CWordShell();
    //Reading template file from common files location as byte array.
    oData = Context.getFile("Template.docx", Constants.LOCATION_COMMON_FILES);
    //Creating instance of document in memory
    //Future file name - Context.getSelectedFile()
    //Template  - oData
    //oWord.Init(Context.getSelectedFile(), oData);
    
    //Creating black document
    oWord.Init(Context.getSelectedFile());
    
    oWord.OutputLnF("Report header: <ARIS:NAME>", "heading 1");
    //Replasing text in headers, footers and main part of document
    oWord.ReplaceText("<ARIS:NAME>", "Test report");
    
    var aSelectedObjDefs = ArisData.getSelectedObjDefs();
    //Creating table example
    var aColWidths = [10, 90];
    oWord.BeginTable(100, aColWidths, "TextLT_NoInd");
    //Table haeder
    oWord.TableRow();
    oWord.TableCellF("#", "Header12", "TextLT_NoInd");
    oWord.TableCellF("Object name", "Header12", "TextLT_NoInd");
    for (var i=0; i<aSelectedObjDefs.length; i++)
    {
        oWord.TableRow();
        oWord.TableCellF(""+(i+1), "Header12", "TextLT_NoInd");
        oWord.TableCellF(aSelectedObjDefs[i].Name(-1), "Header12", "TextLT_NoInd");
    }
    oWord.EndTable();
    
    
    //Writing memory instance of document to Hard drive into ARIS's output directory.
    oWord.Close(); 
    
    //When report is finished, document will be transfered to the client's computer.
    return;
}
main();

 

0
by Ilya Seletkov Author
Posted on Fri, 12/06/2013 - 05:23

Hello!

I've made some service updates to this library.

File attachments
0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock