1. Miller Rhodes
  2. PowerBuilder
  3. Saturday, 20 May 2023 23:11 PM UTC

I am currently using GetFileSaveName in combination with SaveAs so that I can filter the available SaveAsTypes.

There doesn't seem to be any way to send something from the GetFileSaveName that will allow you to know whether 

the user wants headers or not.

In my code below, I am using the file type return to pick the parameters to send to SaveAs. I am using the 'headers' option as the default because I see 

nothing I can grab from the GetFileSaveName to pick whether I want a header or not.

Has anyone found a way to do this ?

integer li_rc

string ls_file, ls_file_type, ls_path

li_rc = GetFileSaveName ( "Select File", ls_path, ls_file, ".XLSX", + "Excel Files (*.XLSX),*.XLSX," + "Excel Files 97-2007 (*.XLS),*.XLS," + "CSV Files (*.CSV),*.CSV," + "Text Files (*.TXT),*.TXT," + "PDF Files (*.PDF),*.PDF," , ls_current_dir, 32770)


If isnull(li_rc) or li_rc <> 1 then return

ls_file_type = Right(ls_file, 3)
ls_file_type = upper(ls_file_type)


Choose Case ls_file_type
Case 'XLS'
dw_report.SaveAs(ls_path, Excel8!, TRUE )

Case 'LSX'
dw_report.SaveAs(ls_path, XLSX!, TRUE )

Case 'TXT'
dw_report.SaveAs(ls_path, Text! , TRUE )

Case 'CSV'
dw_report.SaveAs(ls_path, CSV! , TRUE )

Case 'PDF'
dw_report.Object.DataWindow.Export.PDF.Method = NativePDF!
dw_report.SaveAs(ls_path, PDF! , TRUE )

Case ELSE
Messagebox('Report Window Export','Invalid format chosen. Please try your export again', StopSign! )
Return
End Choose

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Saturday, 20 May 2023 23:32 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Millar;

   What about a low-tech solution ... after the GetFileSaveName command when you know the export type, just issue a Message command & ask the App user if they want headings?

  A variation of the above would be to store the App User's heading default in an INI file and then use that in the SaveAs command automatically.  HTH 

Regards ... Chris 

Comment
  1. Miller Rhodes
  2. Friday, 22 September 2023 22:10 PM UTC
I went with Chris's solution and it works great. Many times, low tech is the way to go and then you can move on
  1. Helpful 2
  1. Chris Pollach @Appeon
  2. Saturday, 23 September 2023 14:05 PM UTC
I love the KISS approach! ;-)
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.