Alpha Video Training
Results 1 to 9 of 9

Thread: Trouble with Excel file generated by report.saveas()

  1. #1
    Member
    Real Name
    Nathan Zeiset
    Join Date
    Jul 2000
    Location
    Ephrata, PA
    Posts
    229

    Default Trouble with Excel file generated by report.saveas()

    I am running a report that I'm saving as an Excel file using the following code:

    :Report.SaveAs("HearingAidQry_Report","Excel",query.filter,query.order,"HearingAidQry_Report.xlsx",.t.)

    The code works fine. It generates the Excel file and then opens it using Microsoft Excel 2010. However, if I then want to save the file with a different filename by going to File, then "Save As" within Excel, I get this error message: "Cannot access 'HearingAidQry_Report.xlsx'." (See attachment.)

    If I then close Excel, and then open the HearingAidQry_report.xlsx file directly, "Save As" works fine. Also, if I open Excel before running the code above, the report will be generated just fine and the "Save As" option in Excel works too.

    Apparently something about using Alpha to open Excel makes the "Save As" function in Excel not work. I found this is the case when using sys_open() function as well. Does anyone know of a way to work around this?

    Thanks!
    Nathan
    Attached Images Attached Images

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Trouble with Excel file generated by report.saveas()

    It seems to work for me with Excel 2007 but the generated file has a plain .xls extension. It might be that the saveas routine doesn't support .xlsx type unless Excel is open.
    There can be only one.

  3. #3
    Member
    Real Name
    Nathan Zeiset
    Join Date
    Jul 2000
    Location
    Ephrata, PA
    Posts
    229

    Default Re: Trouble with Excel file generated by report.saveas()

    Thanks for your response, Stan. Unfortunately, it behaves the same way for me using the .xls extension.

    Nathan

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Trouble with Excel file generated by report.saveas()

    I wonder if Excel 2010 is more picky about the file having been opened by (instance owned by) Alpha? When you use the report.saveas() and the Excel file appears, try closing Alpha and see if you get the same error. Not a workaround, just trying to diagnose.
    There can be only one.

  5. #5
    Member
    Real Name
    Nathan Zeiset
    Join Date
    Jul 2000
    Location
    Ephrata, PA
    Posts
    229

    Default Re: Trouble with Excel file generated by report.saveas()

    I tried closing Alpha, but the error still occurs. It only works if I close Excel and reopen it.

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Trouble with Excel file generated by report.saveas()

    If you want to experiment

    :Report.SaveAs("HearingAidQry_Report","Excel",query.filter,query.order,"HearingAidQry_Report.xlsx") 'not auto open output
    sys_open("HearingAidQry_Report.xlsx") 'might have to specify full path
    There can be only one.

  7. #7
    Member
    Real Name
    Nathan Zeiset
    Join Date
    Jul 2000
    Location
    Ephrata, PA
    Posts
    229

    Default Re: Trouble with Excel file generated by report.saveas()

    I ran sys_open("HearingAidQry_Report.xlsx") from the interactive window, and the behavior is the same. If I close Excel and then restart it and open the file directly, "Save As" works fine.

  8. #8
    Member
    Real Name
    Nathan Zeiset
    Join Date
    Jul 2000
    Location
    Ephrata, PA
    Posts
    229

    Default Re: Trouble with Excel file generated by report.saveas()

    I just discovered that this problem is solved in the current version of Alpha. (I was attempting this in version 12.3, build 2689_4440.) However, I couldn't find anything in the release notes for versions since then that describe this bug. Oh, well, I guess that means an upgrade for the client if they want this resolved.

  9. #9
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,685

    Default Re: Trouble with Excel file generated by report.saveas()

    You could add a toolbar button to the report preview that will let the user open Excel before they save the report
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. Is there a way to format the Excel file generated in the Grid Export to Excel?
    By WindForce in forum Mobile & Browser Applications
    Replies: 13
    Last Post: 01-05-2017, 08:45 PM
  2. Trouble exporting a report to a simple test file
    By Windstarsoftware in forum Alpha Five Version 11 - Desktop Applications
    Replies: 2
    Last Post: 09-19-2013, 11:18 PM
  3. Export To Excel - File is generated on the PC but no dialog for saving is presented
    By Steven P. in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 07-08-2011, 05:07 PM
  4. Replies: 4
    Last Post: 12-02-2005, 09:33 PM
  5. Saving Report as text file or excel file
    By Michael Hadjimichael in forum Alpha Five Version 5
    Replies: 1
    Last Post: 06-02-2004, 05:46 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •