Since v0.27.4, xlwings works with locally synced files on OneDrive, OneDrive for Business, and SharePoint. Some constellations will work out-of-the-box, while others require you to edit the configuration via the xlwings.conf file (see User Config) or the workbook's xlwings.conf sheet (see Workbook Config).
注釈
This documentation is for OneDrive and SharePoint files that are synced to a local folder. This means that both, the Excel and Python file, need to show the green check mark in the File Explorer/Finder as status---a cloud icon will not work. If, in turn, you are looking for the documentation to run xlwings with Excel on the web, see xlwings Server.
問題が発生した場合の簡単な回避策は以下:
Disable the ADD_WORKBOOK_TO_PYTHONPATH setting (either via the checkbox on the Ribbon or via the settings in the xlwings.conf sheet).
Add the directory of your Python source file to the PYTHONPATH---again, either via Ribbon or xlwings.conf sheet.
A lot of the xlwings functionality depends on the workbook's FullName property (via VBA/COM) that returns the local path of the file unless it is saved on OneDrive, OneDrive for Business or SharePoint with AutoSave enabled. In this case, it returns a URL instead.
OneDriveとOneDrive for BusinessのURLは、対応するローカル ファイルにかなり簡単に変換できます。ただし、ローカル ドライブのルート ディレクトリを知る必要がありますが、Windowsでは、通常、OneDriveの環境変数から取得できます。macOSではこれらが存在しないため、OneDriveのルート ディレクトリを取得する必要があります。Windowsでは、SharePointのルートディレクトリも環境変数から得られることがありますが、保証されているわけではありません。macOSの場合は、常に取得する必要があります。
SharePoint, unfortunately, allows you to map the drives locally in any way you want and there's no way to reliably get the local path for these files. On Windows, xlwings first checks the registry for the mapping. If this doesn't work, xlwings checks if the local path is mapped by using the defaults and if the file can't be found, it checks all existing local files on SharePoint. If it finds one with the same name, it'll use this. If, however, it finds more than one with the same name, you will get an error message. In this case, you can either rename the file to something unique across all the locally synced SharePoint files or you can change the SHAREPOINT_WIN/MAC setting to not stop at the root folder but include additional folders. As an example, assume you have the following file structure on your local SharePoint:
My Company LLC/
└── sitename1/
└── myfile.xlsx
└── sitename2 - Documents/
└── myfile.xlsx
In this case, you could either rename one of the files, or you could add a path that goes beyond the root folder (preferably under the xlwings.conf sheet):