Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DBF to fomatted xls spreadsheet
Message
 
To
04/08/2003 12:34:04
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00816537
Message ID:
00816744
Views:
23
Hi Kimberly,

I think I saw this trick in a recent FPA.

Create an HTML fragment with a table defined in it and save it as a file of type .xls:
** copies the contents of the currently selected work area to a file of type XLS formatted as an HTML table

** for demo purposes
CLOSE DATABASES all
USE (ADDBS(_samples) + 'Northwind\customers.dbf')

LOCAL lcHTM
lcHTM = []

TEXT TO lcHTM ADDITIVE TEXTMERGE NOSHOW
<table>
  <tr>
    <th colspan="<<tran(fcount())>>" bgcolor="#FFCC00"><font size="+4" color="#0000CC">Contents of the <<alias()>> table</font></th>
  </tr>
  <tr>
ENDTEXT

FOR lnColumn = 1 TO FCOUNT()
TEXT TO lcHTM ADDITIVE TEXTMERGE NOSHOW
    <th bgcolor="#FFFF33"><<field(lnColumn)>></th>
ENDTEXT
ENDFOR

TEXT TO lcHTM ADDITIVE TEXTMERGE NOSHOW
  </tr>
ENDTEXT

SCAN

TEXT TO lcHTM ADDITIVE TEXTMERGE NOSHOW
  <tr>
ENDTEXT


  FOR lnColumn = 1 TO FCOUNT()
TEXT TO lcHTM ADDITIVE TEXTMERGE NOSHOW
    <td<<IIF(RECNO()%2 = 0, [ bgcolor="#FFFF99"], [])>>><<IIF(lnColumn%3 = 1, [<i>], [])>><<ALLTRIM(TRANSFORM(eval(field(lnColumn))))>><<IIF(lnColumn%3 = 1, [</i>], [])>></td>
ENDTEXT
  ENDFOR

TEXT TO lcHTM ADDITIVE TEXTMERGE NOSHOW
  </tr>
ENDTEXT

ENDSCAN

TEXT TO lcHTM ADDITIVE TEXTMERGE NOSHOW
  </table>
ENDTEXT

LOCAL lcDest
lcDest = GETFILE('xls', 'Excel File', 'Create', 1, 'Create an Excel file')

IF ! EMPTY(lcDest)
  STRTOFILE(lcHTM, lcDest)
ENDIF
Now open the file you created in excel.

Cheers,

Andrew

>To whom it may concern:
>
>I would like some input on how to copy data to an already formatted excel spreadsheet. This is something for very new to me. So if any has any ideas please email me back. Thanks in advance.
>
>Kimberly


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Previous
Reply
Map
View

Click here to load this message in the networking platform