Excel is not visible for Android

Chinmay Dole 200 Reputation points
2025-02-18T11:11:24.62+00:00

Hello,

I have created a test project to show Excel using web view. Here is the GitHub URL

TestWebVeiw. I am trying to open the Excel file using WebView. The Excel is visible on the iPhone, but it shows a blank page when I try to run it on Android. I have attached valid screenshots below. 

iPhone:

Screenshot 2025-02-18 163232

Android:

Screenshot_1739876733

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,942 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 48,581 Reputation points Microsoft Vendor
    2025-02-19T02:01:30.54+00:00

    Hello,

    This is an expected behavior. Android's native Webview does not have the ability to parse documents. Therefore, you need to enable Javascript for the Android platform's Webview and implement the online preview function of Excel through the API provided by Microsoft.

    Please refer to the following code sample:

    public WebViewTest()
    	{
    		InitializeComponent();
    #if ANDROID
            Microsoft.Maui.Handlers.WebViewHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) => {
                handler.PlatformView.Settings.JavaScriptEnabled = true;                 
                handler.PlatformView.Settings.AllowFileAccess = true;                 
                handler.PlatformView.Settings.AllowFileAccessFromFileURLs = true;              
                handler.PlatformView.Settings.AllowUniversalAccessFromFileURLs = true;
            });
            TestWeb.Source = new Uri("https://view.officeapps.live.com/op/view.aspx?src=https://go.microsoft.com/fwlink/?LinkID=521962").ToString();
    #endif
        }
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.