Control Excel with VFP

xiaoxiao2021-03-06  97

Control Excel with VFP

VFP and Excel can be used to process database tables. If it is cleverly combines the advantages of both, it will greatly make our work. For example, we can use the VFP to process data, and use the Excel's preview printing function to print. This requires us to directly control Excel in the VFP.

The following is an introduction to Excel when developing a VFP application project: 1. Create an Excel object Eole = CreateObject ('Excel.Application') 2. Add a new workbook Eole.Workbooks.add 3. Set the third worksheet to activate the worksheet Eole.Worksheets ("Sheet3"). Activate 4. Open the specified workbook Eole.Workbooks.Open ("C: /Temp/ll.xls") 5. Show Excel Window Eole.visible = .t. 6. Change the Excel title bar Eole.caption = "VFP application call Microsoft Excel" 7. Give unit Gtells Eole.cells (1, 4) .value = XM (XM is a database field name) 8. Set the width of the specified column (unit: characters) Eole.activeesheet.columns (1) .ColumnWidth = 5 9. Set the height of the specified line (unit: pound) Eole.activesheet.Rows (1). RowHeight = 1/0.035 (set the line is 1 cm, 1 pound = 0.035 cm) 10. Insert Paging Eole.Worksheets ("Sheet1") in line 18. Rows (18) .pagebreak = 1 11. Delete Paging Eole.Activesheet.columns (4) .pagebreak = 0 12 before column 4. Specifies the boundary width (Borders parameters) ole.activesheet.Range ("B3: D3"). Borders (2) .weight = 3 13. Set the type Eole.activesheet.Range ("B3: D3") of the four border lines. Borders (2) .LINESTYLE = 1 (where Borders parameters: 1- left, 2-, 3-top, 4-bottom, 5 - oblique, 6-oblique /; lineestyle value: 1 and 7- Dominant, 2-fine deficiency, 4- 点 虚, 9-double solid line) 14. Set the header Eole.Activeesheet.pagesetup.centerheader = "Report 1" 15. Set footup Eole.Activeesheet.pagesetup.centerfooter = "Page P Page" 16. Set the header to the top margins of 2 cm Eole.AnderMargin = 2 / 0.035 17. Set the footer to the bottom margins of 3 cm Eole.activesheet.pagesetup.footermargin = 3/0.035 18. Set the top distance to 2 cm Eole.activesheet.pagesetup.topmargin = 2 / 0.035 19. Set the bottom marga to 4 cm Eole.Activesheet.pagesetup.bottommargin = 4 / 0.035 20. Set the left distance to 2 cm VEOLE.Activeesheet.pagesetup.Leftmargin = 2 / 0.035 21. Set the right distance to 2 cm Eole.activesheet.pagesetup.rightmargin = 2 / 0.035 22.

转载请注明原文地址:https://www.9cbs.com/read-123292.html

New Post(0)