MasteringVFP/13/6

出自VFP Wiki

跳轉到: 導航, 搜尋

目錄

開啟Excel 檔的範例

Exl_file = GETFILE('XLS', '選擇或取消', '選擇', 0, '請選擇要開啟的Excel檔')
DO CASE
CASE EMPTY(Exl_file)
Messagebox("並未選擇要開啟的Excel檔",1+32,"訊息視窗")
QUIT
OTHERWISE
? "你選擇要開啟的Excel檔是 "+Exl_file
ENDCASE
oExl=CREATEOBJECT("Excel.application")
if VARTYPE(oExl) <> "O"
= MESSAGEBOX("EXCEL沒有安裝或損壞或因為記憶體不足而無法使用!",64,"提示")
return
endif
oExl.SheetsInNewWorkbook?=1
oExl.Visible=.T.
oExl.workbooks.Open('&Exl_file')
oExl.activesheet.rows(1).insert
oExl.activecell.formular1c1 = "表頭"
with oExl.SELECTION.font
.name = "細明體"
.fontstyle = "normal"
.size = 20
.strikethrough = .f.
.superscript = .f.
.subscript = .f.
.outlinefont = .f.
.shadow = .f.
endwith

匯入Excel檔的範例

Exl_file = GETFILE('XLS', '選擇或取消', '選擇', 0, '請選擇要匯入的Excel檔')
DO CASE
CASE EMPTY(Exl_file)
Messagebox("並未選擇要匯入的Excel檔",1+32,"訊息視窗")
QUIT
OTHERWISE
? "你選擇要匯入的Excel檔是 "+Exl_file
ENDCASE
import from &Exl_file Type xl8
browse

匯出為Excel檔的範例(含欄位名稱)

use Student 
copy to stu_info type XL5 

匯出為CSV 檔的範例(含欄位名稱)

use Student 
copy to stu_info type CSV

匯出為文字檔的範例1(不含欄位名稱)

use Student 
copy to stu_info type DELIMITED

匯出為文字檔的範例2(不含欄位名稱)

use Student 
copy to stu_info type SDF