"'xr2' is an undeclared prefix" error on Export to Excel

Hi,

I have an export script that is causing an error. We have an excel file that we need to export data to, but also need to be able to save the file via excel. The export script works fine in two situations. 1) When no file exists. 2) When the file that exists has not been saved by excel. As soon as we save the file via excel the export results in this error. This is true even if no changes have been made to the file prior to saving it in excel. In addition to resulting in this error, the excel file becomes corrupted and unusable.

The following screenshot is the error received.

image

I have read through the following thread, but do not see a solution contained there.

[XML issue: undeclared variable error in automation script](http://this link)

I am running Toad for SQL Server v6.7.0.176 and Excel for Office 365 (Build 16.0.11126.20234)

Does anyone have a solution or workaround for this?

Thanks in advance for any help!

Just a hunch, but are you saving the export file as an Excel file type? If not, I can foresee possible errors.

Also, try your export using Toad for SQL 6.8… that’s the latest version… and see if perhaps this was a known issue that’s fixed in the latest releases.

Thanks for the reply. Yes, I am exporting to an Excel file from Toad. I have searched the “Resolved Issues” for version 6.8 and do not see this issue addressed. In addition, the thread that I linked appears to deal with the same issue in Toad Data Point as well. Given that, I am not inclined to think that updating Toad would solve this issue. Regardless, I will check with IT to see if our version can be updated.

I have some workarounds planned, but am hoping for a solution that allows us to export directly to the file we will be busing. Any additional ideas are appreciated.

Thanks again for the help.

In the case of your link, where TDP 3.7 generated the same error message as you have, an upgrade of that product did indeed help.

Try upgrading to 6.8 of Toad/SQL Server and check it out. If it doesn’t resolve the issue, share your script (with options) version of Excel your using, and we’ll see if we can reproduce.

This was happening to me when I was trying to export to an Excel file originally created in an older version of Excel. I had to recreate my file in the latest version of Excel.