I'm not sure if this is the proper place to post my question, so please remove it, or move it, if it's not in the proper place.
I want to create a report, which runs on group context, and... for the objects in a given group... it prints in Excel the names... and the graphic representations... of the objects' default symbols. After reading Ms. Klein's tutorials, and looking at the Aris help for some clarifications, I came up with the code below.
But it outputs only the symbols' graphic representations... Without the names of the names of the symbols. Basically, it overwrites the text, and shows only the graphics.
I think that the write( ) method of the Excel workbook overwrites the other content of the report, how can I avoid this?
var localeId = Context.getSelectedLanguage(); var outFile = Context.createOutputObject( Constants.OUTEXCEL, "some_report.xls" ); var workbook = Context.createExcelWorkbook( Context.getSelectedFile( ) ); var sheet = workbook.createSheet( null ); main( ); function main( ) { outFile.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 5 ); outFile.TableRow( ); outFile.TableCell( "Symbol Name", 34, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VCENTER, 5 ); outFile.TableCell( "Symbol Graphic", 34, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VCENTER, 5 ); var groups = ArisData.getSelectedGroups( ); for( var i = 0; i < groups.length; i++ ) { var currentGroup = groups[ i ]; writeGroupObjects( currentGroup ); } outFile.EndTable( "", 100, "Arial", 12, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 5 ); outFile.WriteReport( ); workbook.write( ); } function writeGroupObjects( currentGroup ) { var objectDefinitions = currentGroup.ObjDefList( ); if( objectDefinitions.length > 0 ) { for( var i = 0; i < objectDefinitions.length; i++ ) { var currentObjectDefinition = objectDefinitions[ i ]; var defaultSymbolNum = currentObjectDefinition.getDefaultSymbolNum( ); var filter = ArisData.ActiveFilter( ); var defaultSymbolName = filter.SymbolName( defaultSymbolNum ); var defaultSymbolGraphic = filter.SymbolGraphic( defaultSymbolNum ); var picName = "symbol" + i + ".png"; defaultSymbolGraphic.Save( outFile, picName ); var picture = Context.getFile( picName, Constants.LOCATION_OUTPUT ); outFile.TableRow( ); outFile.TableCell( defaultSymbolName, 34, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VCENTER, 5 ); sheet.setPicture ( picture, 1, i+1, 2, i+2 ); Context.deleteFile( picName ); } } }
Hi Roger,
I had the same issue once, the grpahic you output is put in the top-left corner and effectively hides the text, you just need to add another column to show the text seperately. I would change the whole script like below:
Your first problem was that you created 2 output files and only the last one was opened.
The second, I dont know why you felt you had to save and then delete the images.
script:
var localeId = Context.getSelectedLanguage(); var outFile = Context.createOutputObject( Constants.OUTEXCEL, "some_report.xls" ); main( ); function main( ) { outFile.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 5 ); outFile.TableRow( ); outFile.TableCell( "Symbol Name", 34, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VCENTER, 5 ); outFile.TableCell( "Symbol Graphic", 34, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VCENTER, 5 ); var groups = ArisData.getSelectedGroups( ); for( var i = 0; i < groups.length; i++ ) { var currentGroup = groups[ i ]; writeGroupObjects( currentGroup ); } outFile.EndTable( "", 100, "Arial", 12, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 5 ); outFile.WriteReport( ); } function writeGroupObjects( currentGroup ) { var objectDefinitions = currentGroup.ObjDefList( ); if( objectDefinitions.length > 0 ) { for( var i = 0; i < objectDefinitions.length; i++ ) { var currentObjectDefinition = objectDefinitions[ i ]; var defaultSymbolNum = currentObjectDefinition.getDefaultSymbolNum(); var filter = ArisData.ActiveFilter( ); var defaultSymbolName = filter.SymbolName( defaultSymbolNum ); var defaultSymbolGraphic = filter.SymbolGraphic( defaultSymbolNum ); outFile.TableRow( ); outFile.TableCell( defaultSymbolName, 34, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VCENTER, 5 ); outFile.TableCell("", 34, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, 0, Constants.FMT_LEFT | Constants.FMT_VCENTER, 5 ); outFile.OutGraphic(defaultSymbolGraphic, -1, 20, 20); } } }
I hope this helps, good luck with your scripting.
Rgs,
Francois
Hi,
I used the two functions SymbolGraohic and OutGraphic to display symbol graphics in a word report: outfile.OutGraphic(selectedFilter.SymbolGraphic(symbolNum), -1, 10, 10);
but it works partially.
I can only display graphics of this type “EmfPicture@..." and graphics of this type “BitmapPicture@...” are not displayed.
Do you have any suggestion?
Thanks