alias chart {
var %t
.comopen excel.main excel.application
; %t = $com(excel.main,visible,4,bool,true)
%t = $com(excel.main,workbooks,2,dispatch* excel.books)
%t = $com(excel.books,open,1,bstr*,$mircdirgraph.csv,dispatch* excel.book)
%t = $com(excel.main,worksheets,2,uint,1,dispatch* excel.sheet)
%t = $com(excel.sheet,range,3,bstr,a1:y6,dispatch* excel.range)
%t = $com(excel.sheet,chartobjects,2,dispatch* chobjs)
%t = $com(chobjs,add,1,uint,100,uint,60,uint,400,uint,200,dispatch* chartobj)
%t = $com(chartobj,chart,2,dispatch* excel.chart)
%t = $com(excel.chart,chartwizard,1,dispatch,excel.range,uint,4,uint,2,uint,1,uint,1,uint,1,bool,true,bstr,$+(Dalnet,$lf,$fulldate))
[color:red] [/color]
; retrieving objects to x and y axis
%t = $com(excel.chart,axes,1,uint,1,dispatch* x-axis)
%t = $com(excel.chart,axes,1,uint,2,dispatch* y-axis)
[color:red] [/color]
; set axes colors
setborder x-axis color $rgb(255,0,0)
setborder y-axis color $rgb(255,0,0)
[color:red] [/color]
; show gridlines (true) or not (false)
setgridlines x-axis true
setgridlines y-axis false
[color:red] [/color]
; set gridlines colors
setgridlines x-axis color $rgb(200,200,200)
setgridlines y-axis color $rgb(200,200,200)
[color:red] [/color]
; set gridlines types
setgridlines x-axis linestyle 1
setgridlines y-axis linestyle 1
[color:red] [/color]
; retrieving label objects
%t = $com(x-axis,ticklabels,2,dispatch* x-labels)
%t = $com(y-axis,ticklabels,2,dispatch* y-labels)
[color:red] [/color]
setfont x-labels size 8
setfont y-labels size 8
setfont x-labels color $rgb(60,60,60)
setfont y-labels color $rgb(0,0,0)
[color:red] [/color]
; set x-axis label orientation to -90 degrees
%t = $com(x-labels,orientation,4,int,-90)
[color:red] [/color]
; set labelticks for each hour
%t = $com(x-axis,ticklabelspacing,4,uint,1)
[color:red] [/color]
%t = $com(excel.chart,chartarea,2,dispatch* chartarea)
fillcolor chartarea 44
[color:red] [/color]
%t = $com(excel.chart,charttitle,2,dispatch* title)
%t = $com(title,left,4,uint,100)
%t = $com(title,top,4,uint,5)
[color:red] [/color]
setfont title size 9
setfont title color $rgb(255,0,0)
[color:red] [/color]
; plotarea border
%t = $com(excel.chart,plotarea,2,dispatch* plotarea)
setborder plotarea color $rgb(255,0,0)
[color:red] [/color]
; plotarea color
fillcolor plotarea 2
[color:red] [/color]
; plotarea outer and top coordinates
%t = $com(plotarea,height,4,uint,99999)
%t = $com(plotarea,top,4,uint,32)
[color:red] [/color]
; legend font, fill color, border color
%t = $com(excel.chart,legend,2,dispatch* legend)
[color:red] [/color]
setfont legend size 8
setborder legend color $rgb(255,0,0)
fillcolor legend 2
[color:red] [/color]
; formatting legendkeys: type of line, weight, color
legendkey 1 linestyle 1, weight 3, color $rgb(255,0,0)
legendkey 2 linestyle 1, weight 3, color $rgb(0,255,0)
legendkey 3 linestyle 1, weight 3, color $rgb(0,0,255)
legendkey 4 linestyle 1, weight 3, color $rgb(255,0,255)
legendkey 5 linestyle 1, weight 3, color $rgb(0,0,0)
[color:red] [/color]
%t = $com(legend,left,4,uint,311)
%t = $com(excel.chart,export,1,bstr*,$mircdirchart.jpg)
[color:red] [/color]
:error
tokenize 32 books sheet range charts chart
scon -r if ($com(excel. $!+ $* )) .comclose $!ifmatch
if ($com(excel.book)) .comclose excel.book $com(excel.book,close,1,bool,false)
if ($com(excel.main)) .comclose excel.main $com(excel.main,quit,1)
while ($com(1)) .comclose $ifmatch
}
[color:red] [/color]
alias setfont {
!.echo -q $com($1,font,2,dispatch* font)
.comclose font $com(font,$2,4,uint,$3)
}
[color:red] [/color]
alias setgridlines {
if ($0 == 3) {
!.echo -q $com($1,majorgridlines,2,dispatch* majorgridlines)
setborder majorgridlines $2 $3
.comclose majorgridlines
}
else return $com($1,hasmajorgridlines,4,bool,$2)
}
[color:red] [/color]
alias fillcolor {
!.echo -q $com($1,fill,2,dispatch* fill)
.comclose fill $com(fill,forecolor,2,dispatch* forecolor)
.comclose forecolor $com(forecolor,schemecolor,4,uint,$2)
}
[color:red] [/color]
alias setborder {
!.echo -q $com($1,border,2,dispatch* border)
.comclose border $com(border,$2,4,int,$3)
}
[color:red] [/color]
alias legendkey {
; legendkey 4, linestyle -4118, weight 3, color $rgb(0,0,0)
!.echo -q $com(legend,legendentries,2,uint,$gettok($1,1,44),dispatch* legendentry)
.comclose legendentry $com(legendentry,legendkey,2,dispatch* legendkey)
[color:red] [/color]
tokenize 32 $remove($2-,$chr(44))
while ($0) {
setborder legendkey $1 $2
tokenize 32 $3-
}
.comclose legendkey
}