Mini Kabibi Habibi

Current Path : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/ole/
Upload File :
Current File : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/ole/olexl.sct

.�VERSION =   3.00dataenvironmentdataenvironmentDatanavigationName = "Datanavigation"
12formformForm1�DataSession = 2
Height = 232
Width = 383
DoCreate = .T.
AutoCenter = .T.
Caption = "Automate a Microsoft Excel Spreadsheet"
MaxButton = .F.
MinButton = .T.
HelpContextID = 114
Name = "Form1"
qPROCEDURE Error
Parameters nError, cMethod, nLine

ENDPROC
PROCEDURE Destroy
RELEASE oXLChart1

ENDPROC
PROCEDURE Activate
THIS.c_solutions1.saveHelp
ENDPROC
PROCEDURE Deactivate
IF TYPE("THIS.c_solutions1") = "O" THEN
	THIS.c_solutions1.restoreHelp
ENDIF
ENDPROC
PROCEDURE Init
IF  fontmetric(1, 'MS Sans Serif', 8, '') # 13 OR ;
	fontmetric(4, 'MS Sans Serif', 8, '') # 2 OR ;
	fontmetric(6, 'MS Sans Serif', 8, '') # 5 OR ;
	fontmetric(7, 'MS Sans Serif', 8, '') # 11
	this.setall('fontname', 'Tahoma')  
ELSE
	this.setall('fontname','MS Sans Serif')
ENDIF
this.setall('fontsize',8)


ENDPROC
8�� �a%�r�U4����UNERRORCMETHODNLINE
<��U	OXLCHART1
�����UTHISC_SOLUTIONS1SAVEHELP9%%�C�THIS.c_solutions1b�O��2�
������UTHISC_SOLUTIONS1RESTOREHELP	�%�C��
MS Sans Serif���$�
�!C��
MS Sans Serif���$��!C��
MS Sans Serif���$��!C��
MS Sans Serif���$�����!��C�fontname�Tahoma�������(��C�fontname�
MS Sans Serif�������C�fontsize�����UTHISSETALLError,��DestroyZ��Activates��
Deactivate���Init��1�3q3�2Q�A2d	��A�34Re��	�
(f)shapeshapeShape4Form1cTop = 154
Left = 11
Height = 42
Width = 363
BackStyle = 0
SpecialEffect = 0
Name = "Shape4"
labellabelLabel3Form1�AutoSize = .T.
FontName = "MS Sans Serif"
FontSize = 8
Caption = " Example 2: Chart "
Height = 15
Left = 19
Top = 148
Width = 88
TabIndex = 0
Name = "Label3"
labellabelLabel4Form1�FontName = "MS Sans Serif"
FontSize = 8
WordWrap = .T.
Caption = "This example sends some sample data to Microsoft Excel and creates a bar chart of the data."
Height = 26
Left = 20
Top = 164
Width = 261
TabIndex = 0
Name = "Label4"
shapeshapeShape3Form1bTop = 70
Left = 11
Height = 71
Width = 363
BackStyle = 0
SpecialEffect = 0
Name = "Shape3"
labellabelLabel1Form1�AutoSize = .T.
FontName = "MS Sans Serif"
FontSize = 8
Caption = " Example 1: Trend "
Height = 15
Left = 19
Top = 64
Width = 91
TabIndex = 0
Name = "Label1"
labellabelLabel2Form1KFontName = "MS Sans Serif"
FontSize = 8
WordWrap = .T.
Caption = "This example sends the results of a crosstab query to Microsoft Excel to calculate sales trends for products in the TESTDATA database. The trend information is retrieved from Excel."
Height = 56
Left = 20
Top = 80
Width = 262
TabIndex = 0
Name = "Label2"

commandbutton
commandbuttoncmdChartForm1�Top = 165
Left = 293
Height = 23
Width = 72
FontName = "MS Sans Serif"
FontSize = 8
Caption = "Example \<2"
TabIndex = 2
Name = "cmdChart"
�PROCEDURE Click
#DEFINE TAB	CHR(9)
#DEFINE CRLF	CHR(13)+CHR(10)
#DEFINE DOGS_LOC	"Dogs"
#DEFINE CATS_LOC	"Cats"

LOCAL nTotSeries,i
public oXLChart1
oXLChart1 = GetObject('','excel.chart')
oXLChart1.application.charts[1].haslegend = .F.
oXLChart1.application.visible = .t.
oXLChart1.application.worksheets(1).cells().clear

_cliptext = ""+TAB+CATS_LOC+TAB+DOGS_LOC+CRLF+;
		 "1994"+TAB+"11"+TAB+"22"+CRLF+;
		 "1995"+TAB+"33"+TAB+"44"+CRLF+;
		 "1996"+TAB+"55"+TAB+"55"+CRLF

oXLChart1.application.worksheets(1).cells(1,1).pastespecial
oXLChart1.application.charts[1].autoformat(-4100,1)

* Remove extra series added by Excel
nTotSeries = oXLChart1.application.charts[1].SeriesCollection().count
FOR i = m.nTotSeries to 4 STEP -1
	oXLChart1.application.charts[1].SeriesCollection(m.i).delete
ENDFOR
oXLChart1.application.charts[1].haslegend = .T.


ENDPROC
PROCEDURE Error
Parameters nError, cMethod, nLine
=messageb(message())
cancel

ENDPROC
��� ��~R%�@�U�����7��T��C��excel.chart�\��T��������-��T����a����CC������	���T���C�	 �CatsC�	 �DogsC�
 C�
 �1994C�	 �11C�	 �22C�
 C�
 �1995C�	 �33C�	 �44C�
 C�
 �1996C�	 �55C�	 �55C�
 C�
 ��%���������������
�#����������������T��CC������
�� ����
��(�����������!����������
������T��������a��U
NTOTSERIESI	OXLCHART1APPLICATIONCHARTS	HASLEGENDVISIBLE
WORKSHEETSCELLSCLEARPASTESPECIAL
AUTOFORMATSERIESCOLLECTIONCOUNTDELETE!4������CCE�x���UNERRORCMETHODNLINEClick,��Error���1�q����R1�A�4��A2l��)�behindscenes..\solution.vcx
commandbutton
Behindscenes1Form1<Top = 203
Left = 12
TabIndex = 3
Name = "Behindscenes1"
c_solutions..\solution.vcxcustomC_solutions1Form1FTop = 205
Left = 62
Height = 18
Width = 25
Name = "C_solutions1"

commandbutton
commandbuttoncmdSheetForm1�Top = 80
Left = 293
Height = 23
Width = 72
FontName = "MS Sans Serif"
FontSize = 8
Caption = "Example \<1"
TabIndex = 1
Name = "cmdSheet"
	-PROCEDURE Click
* This program sends the results of a crosstab query to 
* Microsoft Excel to calculate Sales trends for products
* in the TESTDATA database. The trend information is 
* retrieved from Excel.

#DEFINE PRODUCT_LOC "Product"
#DEFINE SALESJAN_LOC "Sales - Jan"
#DEFINE SALESFEB_LOC "Sales - Feb"
#DEFINE SALESMAR_LOC "Sales - Mar"
#DEFINE TREND_LOC "Trend"
#DEFINE QUERYDATA_LOC	"Querying sales data..."
#DEFINE STARTXL_LOC		"Starting Excel..."
#DEFINE TRENDDATA_LOC	"Trend Data Retrieved"

LOCAL i,j,TrendFunc,xlsheet,XLApp,tmpsheet

WAIT WINDOW QUERYDATA_LOC NOWAIT 

LOCAL lcDataDir
lcDataDir = HOME(2)
DO CASE
CASE FILE(HOME(2)+"data\testdata.dbc")
	lcDataDir = HOME(2)
CASE FILE(HOME()+"samples\data\testdata.dbc")
	lcDataDir = HOME() + "Samples\"
OTHERWISE
	MESSAGEBOX(DATAERR_LOC)
	RETURN .F.
ENDCASE
OPEN DATABASE (lcDataDir+"data\testdata.dbc")

SELECT Products.prod_name, MONTH(Orders.order_date),;
  SUM(Orditems.quantity);
 FROM testdata!orders, testdata!orditems, testdata!products;
 WHERE Orders.order_id = Orditems.order_id;
   AND Products.product_id = Orditems.product_id;
   AND Orders.order_date > {^1994/12/31};
 GROUP BY Orditems.product_id, 2, Products.prod_name;
 ORDER BY Products.prod_name, 2;
 INTO CURSOR curSalesData
 
 DO (_GENXTAB) WITH 'ctabSalesData'

SELECT *, N_1 from ctabSalesData INTO ARRAY arrSalesData

WAIT WINDOW STARTXL_LOC NOWAIT 

tmpsheet = GetObject('','excel.sheet')

XLApp = tmpsheet.application

XLApp.Visible = .t.
XLApp.WorkBooks.Add()
XLSheet = XLApp.ActiveSheet

XLSheet.Cells(1,1).Value = PRODUCT_LOC 
XLSheet.Cells(1,2).Value = SALESJAN_LOC 
XLSheet.Cells(1,3).Value = SALESFEB_LOC 
XLSheet.Cells(1,4).Value = SALESMAR_LOC 
XLSheet.Cells(1,5).Value = TREND_LOC 

FOR i = 1 to 10
	FOR j = 1 to 4
		IF ISNULL (arrSalesData(i,j)) THEN
			XLSheet.Cells(i+1,j).Value = 0
		ELSE
			XLSheet.Cells(i+1,j).Value = arrSalesData(i,j)
		ENDIF
	ENDFOR
	TrendFunc = "=TREND(B" + LTRIM(STR(i+1)) + ":D" + LTRIM(STR(i+1)) + ",,4)"
	XLSheet.Cells(i+1,5).Value = TrendFunc
ENDFOR

FOR i = 1 to 10
	IF XLSheet.Cells(i+1,5).Value < 0 THEN
		XLSheet.Cells(i+1,5).Value = 0
	ELSE 
		XLSheet.Cells(i+1,5).Value = INT(XLSheet.Cells(i+1,5).Value)
	ENDIF
ENDFOR

WAIT WINDOW TRENDDATA_LOC TIMEOUT 2
CLOSE DATA


ENDPROC
P�� 77*~%{�2��U:��������!R,:��Querying sales data...�����T��C��Q��
H�`���'�CC��Q�data\testdata.dbc0����T��C��Q��,�CC�Q�samples\data\testdata.dbc0����T��C�Q�Samples\��2�����C��x��B�-��� ����data\testdata.dbc���o�testdata!orders�testdata!orditems�testdata!products���	��C�
�H��C��
���
��������	��
����BA	������������	����	�������curSalesData���)���
ctabSalesData��!o�
ctabSalesData�������R,:��Starting Excel...��T��C��excel.sheet�\��T������T���a����C�����T������&T�����������Product��*T�����������Sales - Jan��*T�����������Sales - Feb��*T�����������Sales - Mar��$T�����������Trend�������(��
��h������(�����%�CC�������#T����������������,T�����������C��������;T���=TREND(BCC��ZA�:DCC��ZA�,,4)��#T���������������������(��
��
�"%�C�������
����#T����������������6T�����������CC������8�����$R,�����Trend Data Retrieved���UIJ	TRENDFUNCXLSHEETXLAPPTMPSHEET	LCDATADIRDATAERR_LOCPRODUCTS	PROD_NAMEORDERS
ORDER_DATEORDITEMSQUANTITYTESTDATAORDER_ID
PRODUCT_IDCURSALESDATAN_1
CTABSALESDATAARRSALESDATAAPPLICATIONVISIBLE	WORKBOOKSADDACTIVESHEETCELLSVALUEClick,��1�r�q����qA�����b���Arq�1��AA�1Ar!1�aAABQ3"	)7cmdclose..\solution.vcx
commandbutton	Cmdclose1Form1RTop = 203
Left = 301
Height = 23
Width = 72
TabIndex = 4
Name = "Cmdclose1"
shapeshapeShape2Form1bTop = 13
Left = 11
Height = 44
Width = 363
BackStyle = 0
SpecialEffect = 0
Name = "Shape2"
labellabelLabel5Form1�FontName = "MS Sans Serif"
FontSize = 8
WordWrap = .T.
Caption = "You can control other applications, such as Microsoft Excel, with OLE Automation."
Height = 26
Left = 20
Top = 23
Width = 343
TabIndex = 0
Name = "Label5"
labellabelLabel6Form1�AutoSize = .T.
FontName = "MS Sans Serif"
FontSize = 8
Caption = " Instructions "
Height = 15
Left = 19
Top = 7
Width = 62
TabIndex = 0
Name = "Label6"
JArial, 0, 9, 5, 15, 12, 32, 3, 0
MS Sans Serif, 0, 8, 5, 13, 11, 11, 2, 0
�DataSession = 2
Height = 232
Width = 383
DoCreate = .T.
AutoCenter = .T.
Caption = "Automate a Microsoft Excel Spreadsheet"
MaxButton = .F.
MinButton = .T.
HelpContextID = 1231539
Name = "Form1"