Blazor Excel 라이브러리 개요

    Infragistics Blazor Excel 라이브러리는 Microsoft Excel 스프레드시트 객체WorkbookWorksheetCellFormula 등 다양한® 도구를 사용해 스프레드시트 데이터를 다룰 수 있게 해줍니다.® Infragistics Blazor Excel 라이브러리는 애플리케이션 데이터를 Excel 스프레드시트로 표현하고 Excel에서 애플리케이션으로 데이터를 전송하는 것을 쉽게 할 수 있게 해줍니다.

    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>
    
    • 정적Workbook.InProcessRuntime 데이터를 현재 실행 시간으로 설정하세요. 이는 다음 코드를 사용하여 수행할 수 있습니다:
    @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 라이브러리 모듈을 가져왔으므로 다음 단계는 통합 문서를 로드하는 것입니다.

    객체를 불러오고 저장Workbook 하려면 실제Workbook 객체의 저장 방법과 정적Load 메서드를 모두 사용할 수 있습니다.

    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

    • Load
    • WorkbookInProcessRuntime
    • Worksheet
    • Workbook