Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel
Message
From
10/08/2003 09:17:29
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Re: Excel
Miscellaneous
Thread ID:
00817098
Message ID:
00818679
Views:
23
The problem is getting poudy big. I tried to populate the sheet one by one. I still didn't apply the format. The problem is that I have about 10 fields and more then 2000 rows. It's slow!!!!

I would be. If your data to populate generate the graph is in a cursor, just use _VFP.DataToClip() to copy it to the clipboard and let Excel sort it out like this:
*** create an instance of excel.
loXl = CREATEOBJECT( 'Excel.Application' )

*** Now add a workbook so we can populate the active worksheet
*** with the data from the query results
loWB = loXl.Workbooks.Add()

*** Now fill in the data
WITH loWb.ActiveSheet
  
  *** Give it a name so we can reference it
  *** after we add a new sheet for the chart
  .Name = "ChartData"
  
  *** Get the number of field in eachs record
  lnFldCount = FCOUNT( 'csrResults' )

  *** Add one because copying the data to the clipboard
  *** adds a row for the field names
  lnRecCnt = RECCOUNT( 'csrResults' ) + 1
  SELECT csrResults
  GO TOP

  *** Copy to clipboard with fields delimited by tabs
  _VFP.DataToClip( 'csrResults', RECCOUNT( 'csrResults' ), 3 )

  *** Get the range of the data in the worksheet
  lcCell = 'A1:' + CHR( 64 + lnFldCount ) + TRANSFORM( lnRecCnt )

  *** And paste it in
  .Paste( .Range( lcCell ) ) 
  
  *** But now we have to make sure that cell A1 is blank
  *** Otherwise the chart is not created correctly
  .Range( "A1" ).Value = ""

  GO TOP IN csrResults
ENDWITH
loChart = loWB.Charts.Add()		
Previous
Reply
Map
View

Click here to load this message in the networking platform