#define xlColumns 2 #define xlWorkbookNormal -4143 #define xlCategory 1 #define xlSeriesAxis 3 #define xlValue 2 Procedure Main #pragma library("ascom10.lib") REQUEST AutomationObject Local oApplication,oSheet,oGraph,oChart,aWork,cRange,aHeader,cFileName Memvar bOldError Private bOldError aHeader:={'Value1','Value2'} aWork:={{'AAA',21},; {'BBB',12},; {'CCC',15},; {'DDD',19},; {'EEE',13}} oApplication:=GetObject( , "Excel.Application" ) oApplication:visible:=.T. oApplication:WorkBooks:add() cRange:='A1:B1' oSheet:=oApplication:Worksheets(1) oSheet:range(cRange):Value:=aHeader cRange:='A2:B6' oSheet:range(cRange):Value:=aWork oGraph:=oSheet:ChartObjects:Add(0,0,500,300) oGraph:Activate() oChart:=oGraph:Chart oChart:SetSourceData(oSheet:cells:Range(cRange),xlColumns) oChart:Axes(xlCategory):HasTitle := .T. oChart:Axes(xlCategory):AxisTitle:Characters:Text :=aHeader[1] oChart:Axes(xlCategory):TickLabels:font:size:=7 oChart:Axes(xlValue):HasTitle := .T. oChart:Axes(xlValue):AxisTitle:Characters:Text :=aHeader[2] oChart:Axes(xlValue):HasMajorGridlines := .F. oChart:Axes(xlValue):TickLabels:font:size:=7 oChart:Legend:font:size:=7 oChart:HasTitle:=.T. oChart:ChartTitle:caption := 'Test' cFileName:=CurDrive()+':\'+CurDir()+'\'+'test.xls' bOldError:=ErrorBlock({|oError|SaveError(oError)}) BEGIN sequence oApplication:WorkBooks(1):saveas(cFileName,xlWorkbookNormal) RECOVER END sequence ErrorBlock(bOldError) oApplication:Quit() oApplication:Destroy() Return Static Function SaveError() Memvar bOldError BREAK ErrorBlock(bOldError) Return .T.