Word Excel viewer Example - #132
Open
ioa747 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Thanks for your effort and interest 💛 in improving the project. It's very appreciated.
Description
Word Excel viewer Example
🔗 Linked GitHub Issues
#40 (comment)
Closes #\40
📋 What is the current behavior?
🚀 What is the new behavior?
Type of changes
Breaking changes 🔥
How and where was this tested?
🖥️ Describe where you tested your changes
System:
Context:
NetJson.ParserNetWebView2.Manager - WebView2NetWebView2.Manager - Bridge🔬 Describe how you tested your changes
Checklist
Additional context
Screenshots
Note to reviewers
Word Excel viewer Example
We have successfully implemented a clean, offline solution for viewing both Word (.docx) and Excel (.xlsx) documents directly inside WebView2 using client-side JavaScript rendering combined with _NetWebView2_SetVirtualHostNameToFolderMapping.
Key Technical Insights:
Chromium Flag Fix: To bypass local fetch/CORS restrictions when loading binary files locally,
we pass the --allow-file-access-from-files switch during manager initialization:
Client-Side Libraries (100% Offline):
Word (.docx): Rendered using docx-preview (requires JSZip).
Excel (.xlsx): Rendered using SheetJS (xlsx.full.min.js), which supports tab switching for multiple worksheets.
Dynamic File Loading Pattern:
Instead of reloading the page with NavigateToString, the HTML viewer page is loaded once.
When selecting a new document via FileOpenDialog, AutoIt updates the active file in the mapped folder and triggers a lightweight JS render function via _NetWebView2_ExecuteScript: