Suporte IronXL para Função AWS Lambda com .NET Core

This article was translated from English: Does it need improvement?
Translated
View the article in English

O IronXL suporta totalmente a Função AWS Lambda para Bibliotecas .NET Standard, aplicativos Core, projetos .NET 5 e .NET 6.

Para adicionar o AWS ToolKit para Visual Studio, siga este link: Usando os Modelos AWS Lambda no AWS Toolkit para Visual Studio.

Instalar o Toolkit AWS no Visual Studio permite que você crie um Projeto de Função AWS Lambda. Você pode aprender como criar um Projeto de Função AWS Lambda usando o Visual Studio através deste link.

Exemplo de Código de Função AWS Lambda em Funcionamento

Após criar um novo projeto de Função AWS Lambda, você pode experimentar este trecho de código:

using System;
using Amazon.Lambda.Core;
using IronXL;

// Ensure this attribute targets your Lambda function
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]

namespace AWSLambdaIronXL
{
    public class Function
    {
        /// <summary>
        /// A simple function that takes a string input and processes it using IronXL.
        /// This specific example creates a new Excel workbook and fills cells with labeled values.
        /// </summary>
        /// <param name="input">The string input for the function</param>
        /// <param name="context">The Lambda context</param>
        /// <returns>A Base64 string representation of the Excel file</returns>
        public string FunctionHandler(string input, ILambdaContext context)
        {
            // Create a new workbook with ExcelFileFormat.XLS
            WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLS);

            // Create a new worksheet named "new_sheet"
            var newSheet = workBook.CreateWorkSheet("new_sheet");

            string columnNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            foreach (char col in columnNames)
            {
                for (int row = 1; row <= 50; row++)
                {
                    // Construct cell name and fill it with data
                    var cellName = $"{col}{row}";
                    newSheet[cellName].Value = $"Cell: {cellName}";
                }
            }

            // Convert the entire workbook to a byte array and then to a Base64 string
            return Convert.ToBase64String(workBook.ToByteArray());
        }
    }
}
using System;
using Amazon.Lambda.Core;
using IronXL;

// Ensure this attribute targets your Lambda function
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]

namespace AWSLambdaIronXL
{
    public class Function
    {
        /// <summary>
        /// A simple function that takes a string input and processes it using IronXL.
        /// This specific example creates a new Excel workbook and fills cells with labeled values.
        /// </summary>
        /// <param name="input">The string input for the function</param>
        /// <param name="context">The Lambda context</param>
        /// <returns>A Base64 string representation of the Excel file</returns>
        public string FunctionHandler(string input, ILambdaContext context)
        {
            // Create a new workbook with ExcelFileFormat.XLS
            WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLS);

            // Create a new worksheet named "new_sheet"
            var newSheet = workBook.CreateWorkSheet("new_sheet");

            string columnNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            foreach (char col in columnNames)
            {
                for (int row = 1; row <= 50; row++)
                {
                    // Construct cell name and fill it with data
                    var cellName = $"{col}{row}";
                    newSheet[cellName].Value = $"Cell: {cellName}";
                }
            }

            // Convert the entire workbook to a byte array and then to a Base64 string
            return Convert.ToBase64String(workBook.ToByteArray());
        }
    }
}
$vbLabelText   $csharpLabel

Os Pacotes NuGet do IronXL disponíveis para implantações estão documentados em nosso guia de instalação do IronXL NuGet.

Perguntas frequentes

Como posso criar um projeto de função AWS Lambda no Visual Studio?

Para criar um projeto de função AWS Lambda no Visual Studio, instale o AWS Toolkit para Visual Studio. Isso permite que você use modelos do AWS Lambda em seus projetos. Você encontra instruções detalhadas na documentação da AWS.

Qual é um exemplo de aplicação do IronXL no AWS Lambda?

Um exemplo de aplicação do IronXL no AWS Lambda é a criação de uma nova planilha do Excel, o preenchimento com dados rotulados e o retorno de uma string Base64 do arquivo do Excel. Isso demonstra como o IronXL pode ser usado para manipular arquivos do Excel em funções do AWS Lambda.

Como faço para converter uma planilha do Excel para Base64 no AWS Lambda usando o IronXL?

Usando o IronXL em uma função AWS Lambda, você pode criar uma planilha e convertê-la em uma matriz de bytes com workBook.ToByteArray() . Em seguida, use Convert.ToBase64String() para obter uma representação em string Base64 da planilha.

É possível usar o IronXL com o .NET 5 em funções AWS Lambda?

Sim, o IronXL oferece suporte completo às funções AWS Lambda for .NET 5, bem como às bibliotecas .NET Standard, aplicativos Core e projetos .NET 6.

Onde posso encontrar recursos para implantar o IronXL com o AWS Lambda?

Os recursos para implantar o IronXL com o AWS Lambda podem ser encontrados no guia de instalação do NuGet do IronXL, que fornece documentação sobre como usar os pacotes NuGet do IronXL para suas implantações.

Como posso solucionar problemas ao usar o IronXL no AWS Lambda?

Certifique-se de ter instalado a versão correta do IronXL e do AWS Toolkit. Revise o código em busca de erros de sintaxe e consulte a documentação do IronXL para obter detalhes sobre a compatibilidade com o AWS Lambda.

Curtis Chau
Redator Técnico

Curtis Chau é bacharel em Ciência da Computação (Universidade Carleton) e se especializa em desenvolvimento front-end, com experiência em Node.js, TypeScript, JavaScript e React. Apaixonado por criar interfaces de usuário intuitivas e esteticamente agradáveis, Curtis gosta de trabalhar com frameworks modernos e criar manuais ...

Leia mais

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/ready_to_started_202509.php
Line: 12
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 489
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/ready_to_started_202509.php
Line: 19
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 489
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

Pronto para começar?
Nuget Downloads 1,890,100 | Versão: 2026.3 acaba de ser lançado

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/still_scrolling_202512.php
Line: 17
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 71
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/still_scrolling_202512.php
Line: 24
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 71
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

Still Scrolling Icon

Ainda está rolando a tela?

Quer provas rápidas? PM > Install-Package IronXl.Excel
executar um exemplo Veja seus dados se transformarem em uma planilha.