onedrive_safe_xlsx
Edit .xlsx files with openpyxl without breaking OneDrive / SharePoint sync and version history.
The problem
openpyxl rebuilds a workbook from its own minimal model when it saves. A real Excel file
has ~26 OOXML parts; openpyxl writes ~9 — it silently drops customXml/*,
docProps/custom.xml, printerSettings, calcChain, and more.
On OneDrive/SharePoint those parts carry the document's identity and library binding. Strip them and your edits can:
- lose the file's version lineage (each save looks like a new/foreign file rather than a new version of the same document), and
- if you do preserve the parts but copy
docProps/core.xmlunchanged, itsdcterms:modified/cp:revisionstay the same, so SharePoint decides nothing changed and won't record a new version.
The fix
save_preserving() edits the data via openpyxl but:
- Keeps every non-data part from the original file (identity preserved).
- Updates the change-tracking in
core.xml—dcterms:modified→ now,cp:lastModifiedBy, and bumpscp:revision— so SharePoint logs a genuine new version.
Usage
import openpyxl
from onedrive_safe_xlsx import save_preserving
wb = openpyxl.load_workbook("Report.xlsx") # an Excel/SharePoint-saved file
wb.active["A1"] = "edited"
save_preserving("Report.xlsx", wb, modified_by="Jane Doe")
Caveats
- Start from an Excel/SharePoint-saved copy — it has the parts to preserve. A file only ever written by openpyxl has nothing to preserve (open + save it in Excel once first).
- Uses
datetime.now(timezone.utc)for the timestamp — cross-platform (Windows/macOS/Linux). - Doesn't manage
rsidco-authoring markers — intended for sequential (not concurrent) edits.
How to cite
If it helps your work, a credit is appreciated — GitHub's "Cite this repository" button
uses CITATION.cff. The licence is permissive (Apache-2.0), so this is a request, not a
requirement.
Licence
Apache-2.0 — see LICENSE. Copyright 2026 Jonathan Corcutt; attribution terms in NOTICE.
Metadata
Release files for onedrive-safe-xlsx 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onedrive_safe_xlsx-0.1.0.tar.gz | 7.8 kB | With provenance | Details for onedrive_safe_xlsx-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onedrive_safe_xlsx-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for onedrive_safe_xlsx-0.1.0-py3-none-any.whl |
Total release size: 16.7 kB
Release files / onedrive_safe_xlsx-0.1.0.tar.gz
| Download URL | onedrive_safe_xlsx-0.1.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7a6a160f80af0114dfd97cab282bda574c833e144b15864e822130e21bcd8b8
|
|
BLAKE2b-256 checksum How to use checksums |
932fdf756e5d487ee38d80c957ddb0768b366a052c650fe29bb0f6f08d0ac349
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logRelease files / onedrive_safe_xlsx-0.1.0-py3-none-any.whl
| Download URL | onedrive_safe_xlsx-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32849915e051f422fb463b4894d7cde287206a3b59a159bce9e0c92510cd1906
|
|
BLAKE2b-256 checksum How to use checksums |
915fcc177a181f2900d27c570e501b46fb8aaeceb803da59764a77eff40a7b68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logSecurity for onedrive-safe-xlsx 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for onedrive_safe_xlsx-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.