This is what i did which meet our user's need but give you enough idea to
match your user's requirements:


// This function only copies visual columns of rows from original datawindow
to
// second datawindow. 
//
// Argument:    a_org_dw -- Original dw (report) which has both visual and
unvisual 
//
columns.
//                                      a_saveas_dw -- A datawindow control
used to generate the new report
//
based on the original dw's visual columns.
nvuo_dw_services nuo_dw_services
string l_col[], l_computes[], l_col_seq[], l_coltype[], l_type
string l_columns, l_dwcolumns, l_dwsyntax, l_new_dwsyntax, l_errortext
int i, j, l_rowcount, l_index1[], l_index2[], l_nbr
long l_pos, l_col_pos[]

// First, get original dw syntax and visual col and compute fields.

nuo_dw_services.nvfn_getobjects(a_org_dw, l_col[], "column", "detail", TRUE)
//create this function yourself.
nuo_dw_services.nvfn_getobjects(a_org_dw, l_computes[], "compute", "detail",
TRUE) //create this function yourself.
nvfn_get_visible_obj(a_org_dw, l_col[]) //create this function yourself.
nvfn_get_visible_obj(a_org_dw, l_computes[]) 
//Get column positions in original dw
for i = 1 to upperbound(l_col)
        l_pos = integer(a_org_dw.describe(l_col[i] + ".x"))
        l_col_pos[i] = l_pos
        l_col_seq[i] = l_col[i]
next
i = i - 1
// Get compute field positions in original dw
for j = 1 to upperbound(l_computes)
        l_pos = integer(a_org_dw.describe(l_computes[j] + ".x"))
        l_col_pos[i + j] = l_pos
        l_col_seq[i + j] = l_computes[j]
next
// ascend array based on the columns and fields positions.
ascend_columns(l_col_pos[], l_col_seq[])
// Get data type for each column and compute field.
for i = 1 to upperbound(l_col_seq)
        l_coltype[i] = a_org_dw.describe(l_col_seq[i] + ".coltype") // data
type of column or field.
        if l_coltype[i] = "char" then l_coltype[i] = "char(10)"
next

// Build a external dw syntax by useing the visual columns and compute
fields of the
// original datawindow and keep the same sequence.
for i = 1 to upperbound(l_col_seq)
        l_columns = l_columns + ic_col_begin + l_coltype[i] + ic_name +
l_col_seq[i] + &
                                        ic_dbname + l_col_seq[i] +
ic_col_end + ic_rtn + " "
        l_dwcolumns = l_dwcolumns + ic_dwcol + ic_dwcol_id + string(i) +
ic_dwcol_name + &
                                          l_col_seq[i] + ic_dwcol_end +
ic_rtn
next
l_new_dwsyntax =  ic_release + ic_rtn + ic_dw + ic_rtn + ic_header + ic_rtn
+&
                                        ic_summary + ic_rtn + ic_footer +
ic_rtn + ic_detail + ic_rtn + ic_table +&
                                        l_columns + ic_table_end + ic_rtn +
l_dwcolumns
                                        
// Create the new datawindow
a_saveas_dw.create(l_new_dwsyntax, l_errortext)
if len(l_errortext) > 0 then return l_errortext

// Copy data from original dw to new dw. Because each dw column has a unique
id but 
// compute field has not. So the copy method will be different.

// Get matching column IDs from both dws.
for i = 1 to upperbound(l_col)
        l_nbr = integer(a_org_dw.describe(l_col[i] + ".id"))
        l_index1[i] = l_nbr
        l_nbr = integer(a_saveas_dw.describe(l_col[i] + ".id"))
        if l_nbr = 0 then return "Visible columns are not match between two
datawindows"
        l_index2[i] = l_nbr
next
// Start to copy data from original dw to new one based on the column ID.
l_rowcount = a_org_dw.rowcount()
for i = 1 to l_rowcount
        a_saveas_dw.insertrow(0)
        for j = 1 to upperbound(l_col)
                a_saveas_dw.object.data[ i, l_index2[j]] =
a_org_dw.object.data[i, l_index1[j]]
        next
next

// Start to copy data in compute fields from original dw to the new one.
for i = 1 to l_rowcount
        for j = 1 to upperbound(l_computes)
                l_type = a_org_dw.describe(l_computes[j] + ".coltype")
                choose case lower(left(l_type, 4))
                        case "char"
                                a_saveas_dw.setitem(i, l_computes[j],
a_org_dw.getitemstring(i, l_computes[j]))
                        case "date"
                                if lower(l_type) = "date" then
                                        a_saveas_dw.setitem(i,
l_computes[j], a_org_dw.getitemdate(i, l_computes[j]))
                                else
                                        a_saveas_dw.setitem(i,
l_computes[j], a_org_dw.getitemdatetime(i, l_computes[j]))
                                end if
                        case "deci"
                                a_saveas_dw.setitem(i, l_computes[j],
a_org_dw.getitemdecimal(i, l_computes[j]))
                        case "numb"
                                a_saveas_dw.setitem(i, l_computes[j],
a_org_dw.getitemnumber(i, l_computes[j]))
                        case "time"
                                a_saveas_dw.setitem(i, l_computes[j],
a_org_dw.getitemtime(i, l_computes[j]))
                end choose
        next
next
return "ok"


Good luck
Larry
> ----------
> From:         [EMAIL PROTECTED][SMTP:[EMAIL PROTECTED]]
> Sent:         Sunday, August 01, 1999 7:46 AM
> To:   [EMAIL PROTECTED]
> Subject:      PFCSIG Exporting dw to Excel
> 
> Non pfc question (I think)
> 
> I want to build a GENERAL routine/function that takes any given dw and
> exports/opens it in Excel.
> I want to export to Excel EXACTLY what the user sees, which means do
> include
> computed columns, summary, meaningful headers,and not inivisble, etc.
>  SaveAs  does not fit the bill as  it doesn't meet most of these demands.
> 
> Any tips, experience, suggestions, etc. are more than welcome
> 
> Thanks !!!!!
> 
> David Lerner
> 
> 
> > [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS,
> ADDRESS
> > A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE:   help
> pfcsig
> > SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]
> 
> [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS, ADDRESS
> A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE:   help pfcsig
> SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]

Reply via email to