You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

2.6    Data to Word report

 

Include the following Entities:

Example reportchild of “Data to Word report”Entity Type: singular obligatory
Chapter 1: Main Dimensionschild of “Example report”Entity Type: singular obligatory
Chapter 2: Deck datachild of “Example report”Entity Type: singular obligatory

In Entity “Example report” the main document will be created which includes the separate documents of the Entities “Chapter 1: Main Dimensions“and “Chapter 2: Deck data“.

Create the following parameters in the Knowledge Browser:

Parameter name

Dimension

Reference

Report_document$

[$]

Report document

Word_file_name$

[$]

Name of Word file

Document_Tag$

[$]

Document tag

TableStyle$

[$]

Word table style information

Example:
ParameterBold:=True,
ParameterBackColor:=wdColorBlack,
Font:=Arial 8.5
OutsideBorder:=wdLineStyleSingle wdLineWidth100pt wdColorAutomatic
InsideGrid:=wdLineStyleSingle wdLineWidth050pt wdColorAutomatic
CaseNumbers:=True
TableAlignment:=wdAlignRowCenter

VBA_Macro$

[$]

VBA Macro that is executed by MS Word

Mode

[BLN]

Mode for creating a VBA table macro by TELITAB2WORD() function.
0<EQ>Saves as WordMacro_TimeStamp_.bas on working directory and returns file name
1<EQ>Returns the complete VBA macro text

If Mode=1 is selected for manipulation by the knowledge engineer, it should be save using a PUT$() function

Transposed

[BLN]

Orientation of Word table
0<EQ>Parameters per column 
1<EQ>Parameter per row

Include the following parameters in Entity “Chapter 1: Main Dimensions “: “Loa”, “Lpp”, “Boa”, “Dm”, “Volume”, “Document_Tag$”, “Report_document$”, “Word_file_name” and QEntityData”.

Create the following relations in Entity “Chapter 1: Main Dimensions”:

  • Loa = ENTITY#(xx).Loa ; In which “xx” is the QEntityID of Entity ”Main Dimensions
  • Lpp = ENTITY#(xx).Lpp ; In which “xx” is the QEntityID of Entity ”Main Dimensions
  • Boa = ENTITY#(xx).Boa ; In which “xx” is the QEntityID of Entity ”Main Dimensions
  • Dm = ENTITY#(xx).Dm ; In which “xx” is the QEntityID of Entity ”Main Dimensions
  • Volume = ENTITY#(xx).Lpp ; In which “xx” is the QEntityID of Entity ”Hydrostatics”. Make sure to instantiate this parameter and remove @MODIFY because you do not want to allow this at this position.
  • Document_Tag$ = "#" + Report_document$ + "#"
  • Word_file_name$ = "main_dimensions_" + STR$(TIME(0)) + ".doc"
  • Report_document$ = WINWORD$ Tutorial_taxonomy_maindimensions.rtf(Word_file_name$,0 , Boa, Dm, Loa, Lpp, Volume)
  • To show computed values during a dialogue write “@SHOW” behind “QEntityData”.

In general, the function WINWORD$ opens and creates an RTF document, saves it as Word document and returns the name of the document. Normally, you have to create a RTF document and store it on the current applications directory (either of the knowledge base, located in Kbs\_<KnowledgeBaseName>\Applic, or the general Applic directory in My Knowledge). We have already created theTutorial_taxonomy_maindimensions.rtf document which you have to place in the right directory.  Download total tutorial

Do the same for the documents report.rtf, Tutorial_deck_data.rtf and excel file Example.xls.

We have created a multi level approach with one main document (report.rtf) and several sub-documents (Tutorial_taxonomy_maindimensions.rtf) and (Tutorial_deck_data.rtf). A time stamp is included in the filenames. See the wiki for a detailed description of both functions WINWORD$ and TIME().

For the second report chapter Entity we do the same as for the first chapter:

Include the following parameters in Entity “Chapter 2: Deck data“, “Deck_data#”, “Document_Tag$”, “Report_document$”, “Word_file_name”, “Mode”, “TableStyle$”, “Transposed”, “VBA_Macro$” and QEntityData”.

Create the following relations in Entity “Chapter 2: Deck data”:

  • Deck_data# = ENTITY#(xx).Deck_data#; In which “xx” is the QEntityID of Entity ”Decks
  • Mode = 0 (0<EQ>Saves as WordMacro_TimeStamp_.bas on working directory and returns file name)
  • Transposed = 0 (0<EQ>Parameters per column)
  • VBA_Macro$ =  TELITAB2WORD$(Deck_data#, 1, TableStyle$, Transposed, Mode) 
    The TELITAB2WORD$ function returns a MS Word macro to create a table in Word based on a given Telitab set, in this case Telitab “Deck_data#”. See the wiki for a detailed description of TELITAB2WORD$ function.
  • Document_Tag$ = "#" + Report_document$ + "#"
  • Word_file_name$ = "deck_data_" + STR$(TIME(0)) + ".doc"
  • Report_document$ = WINWORD$ Tutorial_deck_data.rtf(Word_file_name$, 0, VBA_Macro$)
  • To show computed values during a dialogue write “@SHOW” behind “QEntityData”
  • Parameter “TableStyle$ contains the word table style information. Create the relation as shown in Figure 84. See the wiki for a detailed description of TEXTITEM$() function.

 

Figure 84: Parameter TableStyle$

Finally on the top level we make the overall report:

Include the following parameters in Entity “Example report“: “Report_document$”, “Word_file_name” and QEntityData”.

You have to modify the total report report.rtf in order to let the overall summary report do its work.

In the template of the total report report.rtf we added #ENTITY#(xx).Document_Tag$#. This is the reference to the parameters Document_Tag$# in the relevant Entities. You have to check whether the QEntityID of the two references in the template are correct. If you modify the RTF document, please remember to check it in Quaestor using the Tools>RTF Template Check... option.

Finally create the following relations in Entity “Data to report”.

  • Word_file_name$ = "Report_" + STR$(TIME(0)) + ".doc"
  • Report_document$ = WINWORD$ Report.rtf(Word_file_name$, 0 , ENTITY#(xx).Document_Tag$, ENTITY#(xxx).Document_Tag$) ; In which “xx” is the QEntityID of Entity ” Chapter 1: Main Dimensions” and “xxx” of Entity ““Chapter 2: Deck data”.
  • To show computed values during a dialogue write “@SHOW” behind “QEntityData”.

Back to content | Continue with Data to Excel >>

  • No labels