Blazor Excel 라이브러리 개요
The Infragistics Blazor Excel Library allows you to work with spreadsheet data using familiar Microsoft® Excel® spreadsheet objects like Workbook, Worksheet, Cell, Formula and many more. The Infragistics Blazor Excel Library makes it easy for you to represent the data of your application in an Excel spreadsheet as well as transfer data from Excel into your application.
Blazor Excel Library Example
Requirements
Blazor Excel 라이브러리를 사용하려면 다음 using 문을 추가해야 합니다.
@using Infragistics.Documents.Excel
웹 어셈블리(WASM) Blazor 프로젝트를 사용하는 경우 몇 가지 추가 단계가 있습니다.
- wwwroot/index.html 파일에 다음 스크립트에 대한 참조를 추가합니다.
<script src="_content/IgniteUI.Blazor.Documents.Excel/excel.js"></script>
- Set the static
Workbook.InProcessRuntimeto the current runtime. This can be done by using the following code:
@using Microsoft.JSInterop
@code {
[Inject]
public IJSRuntime Runtime { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
Workbook.InProcessRuntime = (IJSInProcessRuntime)this.Runtime;
}
}
Supported Versions of Microsoft Excel
다음은 지원되는 Excel 버전 목록입니다.**
마이크로소프트 엑셀 97
마이크로소프트 엑셀 2000
마이크로소프트 엑셀 2002
마이크로소프트 엑셀 2003
마이크로소프트 엑셀 2007
마이크로소프트 엑셀 2010
마이크로소프트 엑셀 2013
마이크로소프트 엑셀 2016
Load and Save Workbooks
이제 Excel 라이브러리 모듈을 가져왔으므로 다음 단계는 통합 문서를 로드하는 것입니다.
In order to load and save Workbook objects, you can utilize the save method of the actual Workbook object, as well as its static Load method.
protected override void OnInitialized()
{
var memoryStream = new System.IO.MemoryStream();
workbook.Save(memoryStream);
memoryStream.Position = 0;
var bytes = memoryStream.ToArray();
this.SaveFile(bytes, "fileName.xlsx", string.Empty);
}
private void SaveFile(byte[] bytes, string fileName, string mime)
{
if (this.Runtime is WebAssemblyJSRuntime wasmRuntime)
wasmRuntime.InvokeUnmarshalled<string, string, byte[], bool>("BlazorDownloadFileFast", fileName, mime, bytes);
else if (this.Runtime is IJSInProcessRuntime inProc)
inProc.InvokeVoid("BlazorDownloadFile", fileName, mime, bytes);
}
API References
LoadWorkbookInProcessRuntimeWorksheetWorkbook