Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How to make desktop application Prompt to save excel file with prepopulated filename, working with excel::writer::xlsx. Thanks

  • Comment on Prompt to save file working with excel::writer::xlsx for desktop application

Replies are listed 'Best First'.
Re: Prompt to save file working with excel::writer::xlsx for desktop application
by Corion (Patriarch) on Dec 17, 2018 at 08:17 UTC

    You can simply read data from the console by doing:

    print "Please enter the output filename:\n"; my $filename = <STDIN>; $filename =~ s/\s*$//; # remove newline and other whitespace at the en +d

    For fancier things, there are ExtUtils::MakeMaker::prompt, IO::Prompt and IO::Prompter.

    Also consider allowing the user to pass in the filename directly on the command line instead of asking the user afterwards, or simply directly giving a filename based on the input filename and date/time of run and letting the user rename the file afterwards.

Re: Prompt to save file working with excel::writer::xlsx for desktop application
by Anonymous Monk on Dec 17, 2018 at 09:32 UTC

    I am creating xlsx file using excel::writer::xlsx. I have filename defined, in Perl tk application, I want, when user click on button, it should ask for save i.e user should save where he or she wants. Thanks.

      This does not sound specific to Excel::Writer::XLSX in any way. Did you try Tk::FileSelect? If this does not meet your requirements, please specify in what way.

        while using excel::write::xlsx, we provide constructor filename with path , and file gets generated in the given path. Let's say I have file name, cgi_dec.xlsx,my requirement is, to get the xlsx object and give user save option with the filename populated, where user can choose the directory to save it, after button clicked, file should get created in the user provided directory. I hope this helps to understand the issue. Thanks.

        It seems, I need to somehow manage with Tk::FileSelect. Thanks for the suggestion.