Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Rows To Existing Excel Spreadsheet

Status
Not open for further replies.

ReportMan

Programmer
Aug 13, 2001
40
US
I have a application that needs to both print foxpro reports and populate a pre-formatted excel spreadsheet that mirrors the reports. This is working great by using a scan loop and writing to each cell per row for each record. My problem is that for a certain excel worksheet, I have many more foxpro records than I have rows in the worksheet. Foxpro writes the data just fine but the result is that the extra rows are unformatted. I know by row number when this happens but don't know if it would be easier to insert rows to the worksheet before adding the data or format it add adding.

I am not sure how to do either method and would appreciate any help on the matter. Thanks in advance.
 
ReportMan

You could format the column, here is an example:
Code:
WITH .activesheet
            .NAME = "Allstream traffic"
            nfieldno=AFIELDS(arrfielda,'data_day1')
            FOR N=1 TO nfieldno
               .Cells(1,N).VALUE=arrfielda(N,1)
            ENDFOR
            nrow=2
            SELECT data_day1
            SET FILTER TO ccar = "AT&T"
            GO TOP
            SCAN
               FOR N=1 TO nfieldno
                  cfield='data_day1.'+arrfielda(N,1)
                  .Cells(nrow,N).VALUE=(&cfield)
               ENDFOR
               .Cells(nrow,1).SELECT
               nrow=nrow+1
            ENDSCAN
            STORE nrow TO THIS.Allstreamfinal
            .COLUMNS("K:K").NumberFormat = "#,##0"
            .COLUMNS("L:L").NumberFormat = "#,##0.0"
            .COLUMNS("M:M").NumberFormat = "#,##0.0"
            .COLUMNS("N:N").NumberFormat = "#,##0.0"
            .COLUMNS("O:O").NumberFormat = "#,##0.00"
            .COLUMNS("P:P").NumberFormat = "#,##0.0"
            .COLUMNS("Q:Q").NumberFormat = "#,##0.00"
            .COLUMNS("R:R").NumberFormat = "#,##0.0"
            .COLUMNS("S:S").NumberFormat = "#,##0.00"
            .COLUMNS("T:T").NumberFormat = "#,##0.00"
ENDWITH



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top