Import Excel in .NET MAUI Apps

5 min read
Enable Excel imports in cross-platform .NET MAUI apps.

How to Add Excel and CSV Import in .NET MAUI Apps Using CSVBox

Looking to import Excel or CSV data into your .NET MAUI mobile or desktop app? Whether you’re building a business tool, productivity solution, or data-driven mobile app, enabling users to upload structured data from spreadsheets is a common feature request.

This guide shows how to implement Excel/CSV import in .NET MAUI using CSVBox — a hosted CSV importer with built-in validation, column mapping, and a clean API for retrieving user-submitted data.

If you’re a .NET developer asking:
→ “What’s the best way to add Excel import in .NET MAUI apps?”
→ “How do I handle clean and valid data uploads in cross-platform apps?”
→ “Is there a plug-and-play CSV parser for .NET apps?”

This solution is for you.


Why Importing Spreadsheets is Challenging in .NET MAUI

.NET MAUI is powerful for cross-platform app development, but importing CSV or Excel files presents several complications:

  • No native support for Excel/CSV parsing
  • Platform-specific file access and permissions (iOS, Android, etc.)
  • Validating and mapping user-uploaded columns is error-prone
  • Users expect web-like import experiences, not raw file uploads

Real-World Example Use Cases

  • Internal enterprise apps that rely on spreadsheet workflows
  • Mobile sales tools importing customer lists
  • Finance/reporting apps that need tabular offline data
  • SaaS apps syncing with exported CRM or ERP data

👉 To solve this cleanly, consider using a managed importer like CSVBox.


What Is CSVBox and Why Use It with .NET MAUI?

CSVBox is an embeddable CSV/Excel importer designed for developers. It handles:

  • User-facing import UI (hosted, stylable)
  • Column validation and mapping
  • Parsing Excel and CSV files
  • Returning cleaned, validated JSON output to your app

For .NET MAUI developers, this means:

✅ No need to manually parse or validate spreadsheets
✅ Cross-platform compatibility (via WebView)
✅ Easy API integration using HTTP and callbacks
✅ Secure and sandboxed UI for data upload


Step-by-Step: Integrate CSVBox with .NET MAUI

Here’s how to embed a spreadsheet importer using CSVBox and MAUI components like WebView and HttpClient.

🛠️ What You’ll Need

  • A .NET MAUI Project (on .NET 7 or later)
  • A CSVBox account with an importer configured
  • familiarity with MAUI views and navigation

1. Create a CSVBox Importer

Log into the CSVBox dashboard and create an importer. Configure:

  • Required columns and their names
  • Validations per column (e.g., data type, value constraints)
  • Choose either webhook or fetch API mode

Once configured, you’ll get:

  • A clientKey
  • An importerId

Example:

clientKey = "your-client-key"
importerId = "product_import"

2. Add an Import Page with WebView

Create a new MAUI page to launch the import UI.

In ImportPage.xaml:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             x:Class="MyApp.Pages.ImportPage"
             Title="Import Data">
  <WebView x:Name="ImporterWebView"
           WidthRequest="400"
           HeightRequest="600" />
</ContentPage>

In ImportPage.xaml.cs:

public partial class ImportPage : ContentPage
{
    private const string clientKey = "your-client-key";
    private const string importerId = "product_import";

    public ImportPage()
    {
        InitializeComponent();
        ImporterWebView.Source = new HtmlWebViewSource
        {
            Html = GetImporterHTML()
        };

        ImporterWebView.Navigating += OnWebViewNavigating;
    }

    private string GetImporterHTML()
    {
        return $@"
<!DOCTYPE html>
<html>
<head>
  <script src='https://js.csvbox.io/launch.js'></script>
</head>
<body>
<script>
  const importer = new CsvboxImporter('{clientKey}', '{importerId}', {{
    user: {{
      id: 'user_123',
      name: 'John Doe',
      email: '[email protected]'
    }},
    onComplete: function(results, meta) {{
      window.location.href = 'csvbox://data-imported?import_id=' + meta.import_id;
    }}
  }});
  importer.launch();
</script>
</body>
</html>
";
    }

    private async void OnWebViewNavigating(object sender, WebNavigatingEventArgs e)
    {
        if (e.Url.StartsWith("csvbox://data-imported"))
        {
            e.Cancel = true;
            var importId = System.Web.HttpUtility.ParseQueryString(new Uri(e.Url).Query).Get("import_id");

            var importedJson = await FetchImportedDataAsync(importId);

            await DisplayAlert("Import Complete", $"Import ID: {importId}", "OK");

            // Optional: Parse and use the data
            var products = JsonConvert.DeserializeObject<List<Product>>(importedJson);
        }
    }

    private async Task<string> FetchImportedDataAsync(string importId)
    {
        using HttpClient client = new();
        var url = $"https://api.csvbox.io/import/fetch/{importId}?api_key=your_api_key";

        var response = await client.GetAsync(url);
        return response.IsSuccessStatusCode
            ? await response.Content.ReadAsStringAsync()
            : "{}";
    }
}

3. Push ImportPage from Anywhere in Your App

await Navigation.PushAsync(new ImportPage());

4. Parse and Use Your Imported Data

After fetching, deserialize the JSON to your model:

var data = JsonConvert.DeserializeObject<List<Product>>(importedJson);

You can then:

  • Store it in SQLite for offline access
  • Display in ListView, DataGrid, or Charts
  • Send to your backend or API

Troubleshooting Tips

WebView Not Rendering Importer (iOS/macOS)

Ensure your Info.plist has:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key><true/>
</dict>

Also verify hybrid WebView support is enabled in your MAUI project settings.

Import Complete Callback Not Triggering

Ensure you use a custom URI scheme like csvbox:// in your onComplete redirect.

Avoid using http/https which loads actual web pages and won’t trigger Navigating events.

Importer Not Launching

Test your credentials with a basic browser snippet:

<script>
  new CsvboxImporter('your-client-key', 'your-importer-id').launch();
</script>

Double-check clientKey and importerId spellings and casing.


Why CSVBox Is Ideal for .NET MAUI

CSVBox allows you to delegate complex spreadsheet logic to a hosted service. This keeps your MAUI app:

  • Lightweight and fast
  • Cross-platform without native parsing dependencies
  • Focused on user experience and business logic, not file handling

Benefits Over Manual Parsing

FeatureManual CodeUsing CSVBox
File Format SupportCSV onlyCSV and Excel
Validation/Missing FieldsCustom logicBuilt-in dashboard
UI for Upload/MappingManual viewsHosted UI
Output FormatRaw stringsCleaned JSON
Testing UXDeveloper onlyLive Demo/Preview

Next Steps and Advanced Uses

Now that integration is complete:

  • Enhance with a preview UI before saving
  • Store results offline using SQLite or Realm
  • Use webhooks for backend workflows or CRM sync

Need inspiration?

📄 CSVBox Docs
🧪 Live Importer Demo


Summary: Should You Use CSVBox with .NET MAUI?

If you’re building a cross-platform .NET MAUI app and need Excel or CSV import — CSVBox is a battle-tested tool made for this. You get:

  • Clean, validated spreadsheet import
  • Low-code setup with WebView + HTML
  • Fetch API for receiving data
  • A scalable pattern for mobile and desktop deployments

✅ Whether you’re building an internal tool, B2B SaaS, or mobile CRM — CSVBox makes spreadsheet imports smooth, secure, and scalable.


Looking for a reliable way to add Excel import in .NET MAUI?
CSVBox delivers the best developer experience with minimal code and maximum reliability.

Related Posts