1. Alexander Skorokhodov
  2. PowerBuilder
  3. Thursday, 5 March 2020 03:18 AM UTC

dear Appeon:

when i  pull up the report data in PBL dw_1, i have an option to Save this data in a file

using dw_1.SaveAs().

Then, a pop-up window appears with a drop down list to select the destination file type

with numerous choices: CSV, Excel5, etc, etc.

I have a request from the users to

Limit the drop-down list in the Save As option for reports to csv with headers, text with headers, Excel8 with headers and Excel 12 (.xlsx) with headers.

 

is this possible?

thank you in advance.

sasha

 

 

 

Michael Kramer Accepted Answer Pending Moderation
  1. Friday, 6 March 2020 01:37 AM UTC
  2. PowerBuilder
  3. # 1

Hi, how to ease writing and reading flags/options for GetFileSaveName and its cousin GetFileOpenName >>>

STEP #1: Create new custom NVO. Name = OFN

// *** CLASS = "OFN" ***
// *** Instance variables ***

// ENUM = OFN - Options for GetFileOpenName/GetFileSaveName (PowerScript functions)
// --------------------------------------------------------------------------------
constant long CreatePrompt       =     1
constant long Explorer           =     2
constant long ExtensionDifferent =     4
constant long FileMustExist      =     8
constant long HideReadOnly       =    16
constant long LongNames          =    32
constant long NoChangeDir        =    64
constant long NoDereferenceLinks =   128
constant long NoLongNames        =   256
constant long NoNetworkButton    =   512
constant long NoReadOnlyReturn   =  1024
constant long NoTestFileCreate   =  2048
constant long NoValidate         =  4096
constant long OverwritePrompt    =  8192
constant long PathMustExist      = 16384
constant long _ReadOnly          = 32768

 

STEP #2: Use named constants instead of "magic numbers"

...
ulong flags = OFN.Explorer + OFN.NoReadOnlyReturn + OFN.CreatePrompt

if GetFileSaveName(..., flags) = 1 then
   ...
end if

 

Enjoy, /Michael

Comment
There are no comments made yet.
Alexander Skorokhodov Accepted Answer Pending Moderation
  1. Thursday, 5 March 2020 15:55 PM UTC
  2. PowerBuilder
  3. # 2

Gentlemen:

Thank you for help, i can surely write my own clone of SaveAs, as you had suggested.

I hoped that there would be an "easier" way, but seemingly no luck here.... 

Comment
  1. John Fauss
  2. Thursday, 5 March 2020 18:57 PM UTC
Have you considered Michael's suggestion of using the GetFileSaveName PowerScript function? A single function call can accomplish what you have described. it doesn't get much easier than that. The key is to supply a filter string argument to restrict the file types to only the ones you want. Refer to the Help topic for the similar GetFileOpenName PowerScript function for an example how this is accomplished.
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 5 March 2020 09:28 AM UTC
  2. PowerBuilder
  3. # 3

Alternative to Miguel's suggestions, you could call GetFileSaveName to allow user select destination file. PN Help describe the wealth of options for GetFileSaveName/GetFileOpenName. Here you can also via "Filter" restrict the filetypes any user may select.

HTH /Michael

Comment
  1. Olan Knight
  2. Friday, 6 March 2020 00:36 AM UTC
This is the easy way to accomplish what you wish to do.



Olan
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 5 March 2020 08:19 AM UTC
  2. PowerBuilder
  3. # 4

Create your own:

- datawindow with one row and one column, having dddw or ddlb with the values you want

- once the user selects one of these, do the SaveAs with the correct type.

 

Comment
  1. David Peace
  2. Thursday, 5 March 2020 12:01 PM UTC
Yes, that would be my chosen option. We have system parameters for groups of users that control the file types they are able to saveas.



David
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.