Developer's reference DW2XLS for PowerBuilder

Reference > n_dwr_service_excel > of_save_dw2sheet

Exporting more than one datawindow on a single sheet

Example

integer li_ret = 1
n_dwr_service_parm lnvo_parm
n_dwr_service_excel lnvo_excel

dw_1.dataobject = 'd_test'
dw_1.SetTransObject(sqlca)
dw_1.retrieve()

lnvo_excel = create n_dwr_service_excel 
lnvo_parm = create n_dwr_service_parm

if lnvo_excel.of_create_wb('C:\MY_BOOK.XLS', lnvo_parm) = 1 then

    lnvo_parm.is_sheet_name = 'Example 1'
    lnvo_excel.of_create_multidw_sheet(lnvo_parm)

    // save DW to upper left corner of sheet
    lnvo_excel.of_save_dw2cursheet(dw_1)
    
    // add a horizontal spacer on the right (in units from the previous DW)
    lnvo_excel.of_add_multidw_hspacer(500)
    
    // save next DW on the right
    lnvo_excel.of_save_dw2cursheet(dw_1)

    // force next DW to be exported below leftmost
    lnvo_excel.of_end_multidw_line()
    
    // add a vertical spacer below
    lnvo_excel.of_add_multidw_vspacer(500)
    
    // save next DW below
    lnvo_excel.of_save_dw2cursheet(dw_1)

    // force next DW to be exported below leftmost (optional at the end)
    lnvo_excel.of_end_multidw_line()
    
    // store the sheet to workbook
    lnvo_excel.of_store_multidw_sheet()
    
    // close the workbook
    lnvo_excel.of_close_wb()
end if