Example using Aspose.Cells in Blazor Webassembly

Are there any example codes using Aspose.Cells in Blazor Webassembly? I’ve searched and got a number of links from the internet including the following, but haven’t been able to get my code working. Thanks in advance for any help

Stephen

@steviepca
We have created a sample project for your reference. In the sample project, use Aspose.Cells to add data and graphics, and render them into images for display on the image tag.
Due to limitations in the size of uploaded files, we have deleted the library. After downloading the file, please clean and build the solution again before running. Please refer to the attachment (696.6 KB).

In Index.razor file:

@page "/"

@using SkiaSharp;
@using Aspose.Cells;
@using Aspose.Cells.Drawing;
@using Aspose.Cells.Rendering;

@inject IJSRuntime JSRuntime

<PageTitle>Index</PageTitle>

<img src="@imageSrc" />

@code
{
    private string imageSrc;

    public Index()
    {
        imageSrc = "data:image/png;base64, " + Convert.ToBase64String(CreateFile());
    }

    private byte[] CreateFile()
    {
        Workbook workbook = new Workbook();
        Worksheet sheet = workbook.Worksheets[0];
        sheet.Cells["A1"].Value = "test data for blazor";

        sheet.PageSetup.PrintGridlines = true;
        sheet.PageSetup.PrintArea = "A1:F20";

        ShapeCollection shapes = sheet.Shapes;

        //Add rectangle shape
        shapes.AddRectangle(1, 0, 1, 0, 100, 150);

        //Add line shape
        shapes.AddLine(8, 0, 1, 0, 100, 150);

        //Add oval shape
        shapes.AddOval(13, 0, 1, 0, 100, 150);


        using MemoryStream ms = new();

        SheetRender render = new SheetRender(sheet, new ImageOrPrintOptions());        
        render.ToImage(0, ms);

        byte[] bytes = ms.ToArray();

        return bytes;
    }
}

The result as follows:
result.png (46.0 KB)

Hope helps a bit.