Easy way to use Copy File command with Excel files?

Is there an easy way to use the Copy File, Copy Folder Commands with an Excel file? The code below fails because it is expecting it to be coded as UTF-8
set dataresults to file(ResourcePath(datafilename))
set archivelocation to "\\bheggplant\Repository\Archived_Bots_and_Drones_Data"
Copy file dataresults into folder archivelocation
Thanks,
Dave
Tagged:

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    I think it's failing because Eggplant Functional doesn't support UNC paths. I wouldn't think the file encoding would matter at all since it's using the system calls to do the copy. I was just able to copy an xlsx file from one folder to another with no issues.
  • DaveHesterDaveHester Member ✭✭
    Hi Matt,
    Thanks for your response. Unfortunately even when I switched from UNC to a mapped letter, I received the same errors. I tried two different variations (see below). Is it possible that ePF behaves differently in Windows than on the Mac? Alternately, is it possible that the issue is that the Excel file has formulas in it?
    Thanks, Dave

    Code:

    set dataresults to workbook(ResourcePath("data_BAD-1.xlsx"))
    set archivelocation to "R:/Archived_Bots_and_Drones_Data"
    Copy file dataresults into folder archivelocation

    Error:
    STFileSystemException:
    Failed to copy file or folder Workbook("R:/BotsAndDrones.suite/Resources/data_BAD-1.xlsx") (Error: (null))

    Code:
    set dataresults to file(ResourcePath("data_BAD-1.xlsx"))
    set archivelocation to "R:/Archived_Bots_and_Drones_Data"
    Copy file dataresults into folder archivelocation

    Error:
    STFileException:
    File R:/BotsAndDrones.suite/Resources/data_BAD-1.xlsx couldn't be read using the defaultStringEncoding (UTF8)
  • EggplantMattEggplantMatt ForumAdmin admin
    edited November 12
    Is it possible that ePF behaves differently in Windows than on the Mac?
    There are occasional differences (generally documented) but this isn't one of them and I tested this on Windows.
    In your second example, I think Sensetalk is failing on the first line. When you do "set var to file x", you're reading the file into the variable. You can't do that with an Excel file because it's a binary format. You'll notice the first error says "failed to copy"; the second one doesn't even suggest that it tried. A Workbook is an object inside the file, so you're not reading the contents, and it's being accessed via an Excel API.
    And your first example isn't going to work because you've set data results to be a workbook object and then you're trying to pass that to "file" which is expecting a string defining the path to a file. I think this should work:
    set archivelocation to "R:/Archived_Bots_and_Drones_Data"
    Copy file dataresults into folder archivelocationset dataresults to ResourcePath("data_BAD-1.xlsx")
    Sorry I missed that the first time through.
Sign In or Register to comment.