question

PrathameshShende avatar image
0 Votes"
PrathameshShende asked ZhiLv-MSFT commented

How Do I Upload xls sheet Read it and save it into database in Blazor WASM

I saw so many examples about bulk upload from excel sheet into database. But the problem is all videos and tutorials are in Blazor Server. So many ready example also available on youtube.
I want develop this blazor wasm and also have asp.net core web api hosted with it . So how do I implement it ? any example please or tutorial.

dotnet-aspnet-core-blazor
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @PrathameshShende,

First, you could refer the following article to upload the excel to the server temporary folder via the IFormFile object:

Upload files to a server

Then, refer the following link to import (insert) Excel file data into Database using SqlBulkCopy or OpenXml.

Import (Insert) Excel file data into Database ASP.Net Core MVC

import excel to database using openxml in asp.net core

0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

for Blazor WASM its a standard file upload (<input file>) to the asp.net core webapi. You should be able to find lots of asp.net core examples.

https://docs.microsoft.com/en-us/aspnet/core/blazor/file-uploads?view=aspnetcore-5.0&pivots=server

if you meant to parse the xls sheet in blazor then you need an excel parser that runs in blazor. find a .netstandard 2.0 library version that supports memory streams to read the excel file. if you can not find one, there are javascript ones you could use.

note: with WASM blazor you need to careful of the file sizes

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.