Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

Export Office Documents to Google Workspace

Edit on GitHub

Export Word, Excel, and PowerPoint documents to Google Docs, Sheets, and Slides, import them back, and work with Drive through one shared session.

Packages
Works with
Target frameworks
netstandard2.0, net8.0, net10.0, net472
Verified
Examples compiled against the source on

OfficeIMO.GoogleWorkspace holds the session, credentials, transport, retries, diagnostics, and fidelity policy. Format packages translate one OfficeIMO document type each: OfficeIMO.Word.GoogleDocs, OfficeIMO.Excel.GoogleSheets, and OfficeIMO.PowerPoint.GoogleSlides. OfficeIMO.GoogleWorkspace.Drive covers files and folders, OfficeIMO.GoogleWorkspace.Auth.GoogleApis adapts Google client-library credentials, and OfficeIMO.GoogleWorkspace.Sync reads change feeds.

You want toPage
Create a session from a service account, token, or Google APIs credentialAuthenticate to Google Workspace
Export Word to Google Docs or import a Google DocExport and Import Google Docs
Export Excel to Google Sheets or import a spreadsheetExport and Import Google Sheets
Export PowerPoint to Google SlidesExport and Import Google Slides
List, upload, download, or share Drive filesManage Google Drive Files
Target a shared driveWork with Google Shared Drives
Track Drive changes and apply a sync planTrack Google Drive Changes
Check what each translator supportsGoogle Workspace support matrix

Create a session and export a document

Every translator can build a local plan before it touches Google. TranslationReport entries carry a stable code, source path, severity, chosen action, and count, and GoogleWorkspaceFidelityPolicy decides whether errors or warnings stop the operation.

C#

using OfficeIMO.GoogleWorkspace;
using OfficeIMO.Word;
using OfficeIMO.Word.GoogleDocs;

using var credentials = GoogleServiceAccountCredentialSource.FromFile("service-account.json");
var session = new GoogleWorkspaceSession(credentials, new GoogleWorkspaceSessionOptions {
    ApplicationName = "Reporting service",
    DefaultFolderId = "folder-id",
    MaxRetryCount = 5,
    DiagnosticSink = entry => Console.WriteLine($"{entry.Severity}: {entry.Message}")
});

using WordDocument document = WordDocument.Load("report.docx");
GoogleDocumentReference created = await document.ExportToGoogleDocsAsync(session,
    new GoogleDocsSaveOptions { Title = "Quarterly report" });

Console.WriteLine(created.FileId);

PowerShell

$session = New-OfficeGoogleWorkspaceSession -KeyPath .\Secrets\reporting.json -Scope Documents, DriveFile
try {
    Export-OfficeWordGoogleDocument -Path .\report.docx -Session $session
} finally {
    $session.CredentialSource.Dispose()
}

Update an existing file safely

Import or read the target first, keep its RevisionId (Docs, Slides) or DriveVersion (Sheets), and pass it back in the replace options. The replacement fails if the file changed in between. Overwrite modes exist, but only as an explicit choice. Drive change feeds tell you what to look at; they do not replace the format-specific replacement checks.

Example source