Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:07:41+00:00 2026-06-13T20:07:41+00:00

Our PowerBuilder application generates a report by printing a DataWindow as PDF file. Now

  • 0

Our PowerBuilder application generates a report by printing a DataWindow as PDF file. Now we would like to modify the PB such that an Excel is generated instead of PDF.

In my PB code I tried using the following function:

public function integer save_dw_to_file (datawindow adw_datawindow, string as_filename, string as_folder);
  string ls_tmp_file_xls
  ls_tmp_file_xls = as_filename+'_temp.xls'
  adw_datawindow.saveas(ls_tmp_file_xls,Excel!,true)
  return 1
end function

Note: adw_datawindow is the DataWindow that I want to print; as_filename is the output filename.
However, this seems not work because I got an error when I open the file.

Do you know how to do this? Our environment:

PB Version: PB 12 Classic; Excel Version: MS Excel 2007

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:07:43+00:00Added an answer on June 13, 2026 at 8:07 pm

    Your code should work; you should check the error code because it will have meaningful info.

    It could be a permissions (file) issue, file contention issue, bad folder (invalid characters), etc., existing file that is locked. Wouldn’t hurt to see if the file/folder exists first. You can check for the file using FileExists(as_filename) or you can check a folder by DirectoryExists(as_directory).

    You could try Excel8! for Excel version 8 or higher but I think your Excel! should work just fine.

    // Add saveastype as parameter to function
    public function integer save_dw_to_file (datawindow adw_datawindow, &
                                             string as_filename, &
                                             string as_folder, &
                                             SaveAsType sat_SaveType)
    
    int li_rc
    string ls_tmp_file
    ls_tmp_file = as_filename
    
    // add file extension based on saveastype
    choose case sat_SaveType
    case Excel!, Excel5!, Excel8!
       ls_tmp_file += '_temp.xls'
    case PDF!
       ls_tmp_file += '_temp.pdf'
    end choose
    
    if FileExists ( ls_tmp_file ) Then  
       if MessageBox('File already exists','Would you like to replace: ' + &
           ls_tmp_file + '?', Question!, YesNo!, 2) = 2 then
          return -1
       end if
    end if 
    
    // save type based on parameter to function
    li_rc = adw_datawindow.saveas(ls_tmp_file, sat_SaveType, true)
    if li_rc = -1 then
        MessageBox('Error saving file','Unable to save file: ' + ls_tmp_file)
    end if
    
    return li_rc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our application is a Java-GWT application that uses Guice-Persist and Guice-Servlet extensively. We have
Our product is halted at Java version 1.5.0_13 and we would like to upgrade.
In PowerBuilder, to locally deploy the application, you can use the .srj file which
Our Application has a Class that wraps Jersey REST functionality. One Method is public
Our existing application reads some floating point numbers from a file. The numbers are
Our company has a share point document server where the UNC looks something like
Our PHP application makes use of json_encode($myObject) a lot, in conjunction with the mustache
Our company web site generates feeds, but for some reason, white space is being
Our application uses an animation to fade out a message window when it's closed.
Our workflow currently has developers working on locally hosted copies of our web application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.