|
VFP ·R¥ÎªÌªÀ°Ï ¥»°Q½×°Ï¬° Visual Foxpro ·R¥ÎªÌ¸gÅç¥æ¬yªº¦a¤è, ½Ð¦h¦h§Q¥Î"·j´M"ªº¥\¯à, ¥ý¬d¬Ý¬Ý¦³µL«e¨Ò¥i´`, ¦pªGÁÙ¦³¤£À´ªº¦Aµo°Ý. ³¡¥÷¥DÃD¦³ªþ¥[ÀÉ®×, ¶·¥ýµù¥U¦¨¬°ªÀ°Ï©~¥Á¤~¥i¥H¤U¸ü.
|
¤W¤@½g¥DÃD :: ¤U¤@½g¥DÃD |
µoªí¤H |
¤º®e |
Ruey
µù¥U®É¶¡: 2003-03-12 ¤å³¹: 1698 ¨Ó¦Û: tunglo
²Ä 1 ¼Ó
|
µoªí©ó: ¬P´Á¤G ¤K¤ë 26, 2003 1:34 pm ¤å³¹¥DÃD: DBF¾É¤JExcelªº¤èªk(Âà¶K) |
|
|
¨Ó·½:vfptop gggg
VFPªºDBF¾É¥X¨ìEXECEL¤èªk¡A¨Ñ°Ñ¦Ò
§A¥i¥Î¤@¤U©R¥O¾É¥X¨ìEXECEL
Copy to filename type xls
¤]¥i¥Î¤U¦C¨ç±Â¾É¥X¨ìEXECLE
¥N½X: |
****************************************
* ¥Í¦¨EXCELÀÉ *
****************************************
Function ToExcel
Lparameters ExcelFile,OutField,PageSet,OtherSet
*ExcelFile-¥Í¦¨ªºEXCELÀɮצW (¥²»Ýªº°Ñ¼Æ)
*OutField-¿é¥XªºÄæ¦ì ¦C1-Äæ¦ì¦W ¦C2-¼ÐÃD ¦C3-¼e«×(=-1¬°¦Û°Ê) ¦C4-®æ¦¡²Å (¥i¬Ù²¤)
*PageSet-¶±³]¸m ¦C1-³]¸mªº±M®× ¦C2-³]¸mªºÈ (¥i¬Ù²¤,PageSetªº¥i¥ÎȽЬݵ{¦¡)
*OtherSet-¨ä¥L³]¸m (¥i¬Ù²¤,OtherSetªº¥i¥ÎȽЬݵ{¦¡) , garfieldµù: ¥Î¶Ç§}ªº¤è¦¡¶Ç¨Ó°}¦C¸ê®Æ.
*¨Ï¥Î¥»¨ç¼Æ¤§«e,½Ð¥ý¤Á´«¨ìn¿é¥Xªº¤u§@°Ï;¨ä¦¸¥u¤ä´©Äæ¦ì,¤£¤ä´©¹Bºâ¦¡
*Äæ¦ì¤]¤£¤ä´©³Æµù«¬©M³q¥Î«¬
*¦pªG¥Î¤á¥¿¦b¨Ï¥ÎEXCEL½s¿è¦P¦WªºÀÉ,©ÎªÌ±Nn¥Í¦¨ªºEXCELÀɳQ¦û¥Î
*¤]·|³y¦¨µ{¦¡¥X¿ù,¨Ï¥Î¥»¨ç¼Æ¤§«e«ØijÃö³¬EXCEL
Do CASE
Case PARAMETERS()=1
Store null TO OutField,PageSet,OtherSet
Case PARAMETERS()=2
Store null TO PageSet,OtherSet
Case PARAMETERS()=3
Store null TO OtherSet
Endcase
Local i,OutFields,ExcelApp,ExcelAppRang
For i=1 TO IIF(TYPE("OutField(1)")="U" OR ISNULL(OutField),0,ALEN(OutField,1))
OutField(i,1)=UPPER(ALLTRIM(OutField(i,1)))
Next
For i=1 TO IIF(TYPE("PageSet(1)")="U" OR ISNULL(PageSet),0,ALEN(PageSet,1))
PageSet(i,1)=UPPER(ALLTRIM(PageSet(i,1)))
Next
For i=1 TO IIF(TYPE("OtherSet(1)")="U" OR ISNULL(OtherSet),0,ALEN(OtherSet,1))
OtherSet(i,1)=UPPER(ALLTRIM(OtherSet(i,1)))
Next
OutFields=""
For i=1 TO IIF(TYPE("OutField(1)")="U" OR ISNULL(OutField),0,ALEN(OutField,1))
OutFields=OutFields+IIF(EMPTY(OutFields),"",",")+OutField(i,1)
Next
If ISNULL(OutField) OR OutField(1)="AUTO_SET" AND OutField(2)="-1" &&¥Í¦¨EXCELÀÉ
Copy TO (ExcelFile) XL5
Else
Copy TO (ExcelFile) FIELDS &OutFields XL5
Endif
ExcelApp=CREATEOBJECT("Excel.application") &&³X°ÝEXCEL
If Type("ExcelApp")#"O"
Wait CLEAR
Messagebox( "³X°ÝExcel¥¢±Ñ¡I½ÐÀˬd§Aªº¨t²Î¬O§_¥¿½T¦w¸Ë Excel ³nÅé¡I"+CHR(13)+CHR(13)+;
"¦ý¤w¸g¥Í¦¨¥¼±a®æ¦¡ªº Excel ÀÉ:"+ExcelFile,48,"Excel¤£¥¿±`")
Return .f.
Endif
ExcelApp.Visible =.f.
ExcelApp.Caption ="¥Í¦¨EXCEL" &&¼ÐÃD
ExcelApp.Workbooks.Open(ExcelFile) &&¥´¶}¤å¥ó
ExcelApp.Workbooks(1).ActiveSheet.Name="Test" &&¤u§@ªí¦W
ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).PageSetup &&¶±³]¸mª«¥ó
For i=1 TO IIF(TYPE("PageSet(1)")="U" OR ISNULL(PageSet),0,ALEN(PageSet,1))
Do CASE
Case PageSet(i,1)=UPPER("PaperSize") &&¯È±iÃþ«¬
ExcelAppRang.PaperSize=PageSet(i,2)
Case PageSet(i,1)=UPPER("Orientation") &&¦C¦L¤è¦V
ExcelAppRang.Orientation=PageSet(i,2)
Case PageSet(i,1)=UPPER("TopMargin") &&¶³»ªÅ
ExcelAppRang.TopMargin=PageSet(i,2)
Case PageSet(i,1)=UPPER("BottomMargin") &&¶©³ªÅ
ExcelAppRang.BottomMargin=PageSet(i,2)
Case PageSet(i,1)=UPPER("LeftMargin") &&¶¥ªªÅ
ExcelAppRang.LeftMargin=PageSet(i,2)
Case PageSet(i,1)=UPPER("RightMargin") &&¶¥kªÅ
ExcelAppRang.RightMargin=PageSet(i,2)
Case PageSet(i,1)=UPPER("HeaderMargin") &&¶¬Ü¦ì¸m
ExcelAppRang.HeaderMargin=PageSet(i,2)
Case PageSet(i,1)=UPPER("FooterMargin") &&¶¸}¦ì¸m
ExcelAppRang.FooterMargin=PageSet(i,2)
Case PageSet(i,1)=UPPER("PrintTitleRows") &&¦æ¼ÐÃD
ExcelAppRang.PrintTitleRows=PageSet(i,2)
Case PageSet(i,1)=UPPER("PrintTitleColumns") &&¦C¼ÐÃD
ExcelAppRang.PrintTitleColumns=PageSet(i,2)
Case PageSet(i,1)=UPPER("LeftHeader") &&¥ª¶¬Ü
ExcelAppRang.LeftHeader=PageSet(i,2)
Case PageSet(i,1)=UPPER("CenterHeader") &&¤¤¶¬Ü
ExcelAppRang.CenterHeader=PageSet(i,2)
Case PageSet(i,1)=UPPER("RightHeader") &&¥k¶¬Ü
ExcelAppRang.RightHeader=PageSet(i,2)
Case PageSet(i,1)=UPPER("LeftFooter") &&¥ª¶¸}
ExcelAppRang.LeftFooter=PageSet(i,2)
Case PageSet(i,1)=UPPER("CenterFooter") &&¤¤¶¸}
ExcelAppRang.CenterFooter=PageSet(i,2)
Case PageSet(i,1)=UPPER("RightFooter") &&¥k¶¸}
ExcelAppRang.RightFooter=PageSet(i,2)
Case PageSet(i,1)=UPPER("CenterHorizontally") &&¶±¤ô¥©~¤¤
ExcelAppRang.CenterHorizontally=PageSet(i,2)
Case PageSet(i,1)=UPPER("CenterVertically") &&¶±««ª½©~¤¤
ExcelAppRang.CenterVertically=PageSet(i,2)
Endcase
Next
If ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1"
For i=1 TO FCOUNT()
If !ISNULL(OutField) AND ASCAN(OutField,UPPER(FIELD(i)))>0
ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,i).value=OutField(ASCAN(OutField,UPPER(FIELD(i)))+1) &&¼ÐÃD
*IF !ISNULL(OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)) AND TYPE("OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)")="N" AND OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)#-1
* ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth =OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)
*ENDIF
If !ISNULL(OutField(ASCAN(OutField,UPPER(FIELD(i)))+3)) AND !EMPTY(OutField(ASCAN(OutField,UPPER(FIELD(i)))+3)) &&®æ¦¡¼Òª©
ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).NumberFormatLocal=OutField(ASCAN(OutField,UPPER(FIELD(i)))+3)
Endif
Endif
Next
Else
For i=1 TO ALEN(OutField,1)
If !ISNULL(OutField(i,2)) AND !EMPTY(OutField(i,2)) &&¼ÐÃD¦WºÙ
ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,i).value=OutField(i,2)
Endif
*IF !ISNULL(OutField(i,3)) AND TYPE("OutField(i,3)")="N" AND OutField(i,3)#-1 &&¦C¼e
* ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth =OutField(i,3)
*ENDIF
If !ISNULL(OutField(i,4)) AND !EMPTY(OutField(i,4)) &&®æ¦¡¼Òª©
ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).NumberFormatLocal=OutField(i,4)
Endif
Next
Endif
If ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1" &&¿ï¾Ü¼ÐÃD¦æ½d³ò
ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
ExcelApp.Workbooks(1).Sheets(1).Application.Cells( 1,FCOUNT()))
Else
ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
ExcelApp.Workbooks(1).Sheets(1).Application.Cells( 1,ALEN(OutField,1)))
Endif
ExcelAppRang.HorizontalAlignment=3 &&¤ô¥©~¤¤
ExcelAppRang.VerticalAlignment=2 &&««ª½©~¤¤
ExcelAppRang.Font.Bold = .t.
If ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1" &&¿ï¾Üªí®æ½d³ò
ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
ExcelApp.Workbooks(1).Sheets(1).Application.Cells(RECCOUNT()+1,FCOUNT()))
Else
ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
ExcelApp.Workbooks(1).Sheets(1).Application.Cells(RECCOUNT()+1,ALEN(OutField,1)))
Endif
******
* garfieldµù: OtherSet[ n§ïÅܳ]©wȪººØÃþ¦WºÙ, ³]©wÈ ]
If !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("FontSize"))#0 &&¦rÅé¤j¤p
ExcelAppRang.Font.Size=OtherSet(ASCAN(OtherSet,UPPER("FontSize"))+1)
Else
ExcelAppRang.Font.Size=10
Endif
If !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("FontName"))#0 &&¦rÅé
ExcelAppRang.Font.Name=OtherSet(ASCAN(OtherSet,UPPER("FontName"))+1)
Else
ExcelAppRang.Font.Name="§ºÅé"
Endif
If !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("LineStyle"))#0 &&ªí®æ½uªºÃþ«¬
Store OtherSet(ASCAN(OtherSet,UPPER("LineStyle"))+1) TO ;
ExcelAppRang.Borders(1).LineStyle,;
ExcelAppRang.Borders(2).LineStyle,;
ExcelAppRang.Borders(3).LineStyle,;
ExcelAppRang.Borders(4).LineStyle
Else
Store 1 TO ;
ExcelAppRang.Borders(1).LineStyle,;
ExcelAppRang.Borders(2).LineStyle,;
ExcelAppRang.Borders(3).LineStyle,;
ExcelAppRang.Borders(4).LineStyle
Endif
If !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("Weight"))#0 &&ªí®æ½uªº¼e«×,·íLineStyle=1®É¦³®Ä
Store OtherSet(ASCAN(OtherSet,UPPER("Weight"))+1) TO ;
ExcelAppRang.Borders(1).Weight,;
ExcelAppRang.Borders(2).Weight,;
ExcelAppRang.Borders(3).Weight,;
ExcelAppRang.Borders(4).Weight
Else
Store 2 TO ;
ExcelAppRang.Borders(1).Weight,;
ExcelAppRang.Borders(2).Weight,;
ExcelAppRang.Borders(3).Weight,;
ExcelAppRang.Borders(4).Weight
Endif
If ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1" &&¦C¼e
For i=1 TO FCOUNT()
If !ISNULL(OutField) AND ASCAN(OutField,UPPER(FIELD(i)))>0 and OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)#-1
ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth =OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)
Else
ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).AutoFit
Endif
Next
Else
For i=1 TO ALEN(OutField,1)
If OutField( i, 3)=-1
ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).AutoFit
Else
ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth=OutField( i, 3)
Endif
Next
Endif
ExcelApp.Workbooks(1).Save() &&«O¦s
ExcelApp.Quit &&Ãö³¬
Release ExcelApp,ExcelAppRang
Return .t.
****************************************
|
_________________ #############################
§Ö¼Ö¶ý«}¨t¦C©¯ºÖ¦v°t,³Ü¤Q¥þÂû´ö~ì¨Ó©¯ºÖ¨º»ò²³æ!!
¾Ç·|VFP¨Ï¥ÎªÌªÀ°Ïªº·j´M,Code¤~·|§ó¦³½ì~
############################# |
|
¦^³»ºÝ |
|
|
Erwin
µù¥U®É¶¡: 2003-03-28 ¤å³¹: 97 ¨Ó¦Û: ¥x¥_
²Ä 2 ¼Ó
|
µoªí©ó: ¬P´Á¤G ¤K¤ë 26, 2003 4:11 pm ¤å³¹¥DÃD: |
|
|
§Úµo²{¥Îcopy to filename type xls ®ÉªºexcelÀɺ¡·|·íªº
«á¨Ó§Ú³£§ï¥Î copy to filename type xl5 ´N¨S¨Æ, ¤£ª¾¨ä¥L¤H¬O§_¤]¬O¤@¼Ë |
|
¦^³»ºÝ |
|
|
Erwin
µù¥U®É¶¡: 2003-03-28 ¤å³¹: 97 ¨Ó¦Û: ¥x¥_
²Ä 3 ¼Ó
|
µoªí©ó: ¬P´Á¤T ¤K¤ë 27, 2003 12:03 am ¤å³¹¥DÃD: |
|
|
§Ú«üªº¬OExcel±`·|µL½tµL¬G·í±¼ |
|
¦^³»ºÝ |
|
|
elleryq
µù¥U®É¶¡: 2007-06-21 ¤å³¹: 768
²Ä 4 ¼Ó
|
µoªí©ó: ¬P´Á¤T ¤K¤ë 27, 2003 9:52 am ¤å³¹¥DÃD: |
|
|
¦b Help ¤¤¦³¼g
type xls ¬O¦´Áª©¥»ªº excel ®æ¦¡
type xl5 «h¬O Excel 5.0
type xl8 «h¬O 8.0 ¥H«á,¤£¹L³oÓ§Ú¦b 6.0 ¬O¸Õ¥¢±Ñªº,ÁöµM Help ¸Ì±¦³¼g.
type csv «h¬O¥H³r¸¹¤À¹jªº¤å¦rÀÉ®×,Excel ¤]¥i¥HŪ¨ú.
¥Î OLE Automation ªº³t«×¸ûºC¬O¨ä¯ÊÂI
¤£¹L¥i¥Hºî¦X¨âªÌªºÀuÂI
¥ý¥Î copy to ±N¸ê®Æ¥ý¥á¨ì xls Àɮפ¤
¨Ï¥Î getobject() ¨ú±o excel instance «á,¦A¥Î OLE Automation ¤è¦¡¨Óµe½u,¶ñ¶º¶§Àµ¥.... |
|
¦^³»ºÝ |
|
|
Erwin
µù¥U®É¶¡: 2003-03-28 ¤å³¹: 97 ¨Ó¦Û: ¥x¥_
²Ä 5 ¼Ó
|
µoªí©ó: ¬P´Á¤T ¤K¤ë 27, 2003 9:58 am ¤å³¹¥DÃD: |
|
|
§Ú¥Î XL5 ¥H«á´N¤£¤Ó·|·í¤F, ©Ò¥H´N¤£·Q·d±o¤Ó³Â·Ð
ÁÙ¬OÄ~Äò¥Î COPY TO FILENAME XL5 ´N¦n |
|
¦^³»ºÝ |
|
|
©b¶]ªº·R±¡
µù¥U®É¶¡: 2003-08-28 ¤å³¹: 27
²Ä 6 ¼Ó
|
µoªí©ó: ¬P´Á¥| ¤K¤ë 28, 2003 5:51 pm ¤å³¹¥DÃD: |
|
|
¤µ¤Ñ¦¬Ã¬¥i¯u¤£¤Ö°Ú¡I _________________ delphi vf sql |
|
¦^³»ºÝ |
|
|
|
|
±z µLªk ¦b³oÓª©±µoªí¤å³¹ ±z µLªk ¦b³oÓª©±¦^ÂФ峹 ±z µLªk ¦b³oÓª©±½s¿è¤å³¹ ±z µLªk ¦b³oÓª©±§R°£¤å³¹ ±z µLªk ¦b³oÓª©±¶i¦æ§ë²¼ ±z µLªk ¦b³oÓª©±ªþ¥[ÀÉ®× ±z µLªk ¦b³oÓª©±¤U¸üÀÉ®×
|
Powered by phpBB © 2001, 2005 phpBB Group ¥¿Å餤¤å»y¨t¥Ñ phpbb-tw ºûÅ@»s§@
|