IronXL Support for AWS Lambda Function with .NET Core

IronXL fully supports AWS Lambda Function for .NET Standard Libraries, Core applications, .NET 5, and .NET 6 projects.

To add AWS ToolKit for Visual Studio, follow this link: Using the AWS Lambda Templates in the AWS Toolkit for Visual Studio.

Installing AWS Toolkit into Visual Studio enables you to create an AWS Lambda Function Project. You can learn how to create an AWS Lambda Function Project using Visual Studio through this link.

Working AWS Lambda Function Code Example

After creating a new AWS Lambda Function project, you can try this code snippet:

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());
        }
    }
}
Imports System
Imports Amazon.Lambda.Core
Imports IronXL

' Ensure this attribute targets your Lambda function
<Assembly: LambdaSerializer(GetType(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 Function FunctionHandler(ByVal input As String, ByVal context As ILambdaContext) As String
			' Create a new workbook with ExcelFileFormat.XLS
			Dim workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLS)

			' Create a new worksheet named "new_sheet"
			Dim newSheet = workBook.CreateWorkSheet("new_sheet")

			Dim columnNames As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			For Each col As Char In columnNames
				For row As Integer = 1 To 50
					' Construct cell name and fill it with data
					Dim cellName = $"{col}{row}"
					newSheet(cellName).Value = $"Cell: {cellName}"
				Next row
			Next col

			' Convert the entire workbook to a byte array and then to a Base64 string
			Return Convert.ToBase64String(workBook.ToByteArray())
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

IronXL NuGet Packages available for deployments are documented in our IronXL NuGet installation guide.

Frequently Asked Questions

What is IronXL's support for AWS Lambda Function?

IronXL fully supports AWS Lambda Function for .NET Standard Libraries, Core applications, .NET 5, and .NET 6 projects.

How can I add AWS Toolkit for Visual Studio?

To add AWS Toolkit for Visual Studio, follow the link to the AWS Lambda Templates in the AWS Toolkit for Visual Studio documentation.

What does the AWS Toolkit enable you to do?

Installing AWS Toolkit into Visual Studio enables you to create an AWS Lambda Function Project.

Where can I learn how to create an AWS Lambda Function Project using Visual Studio?

You can learn how to create an AWS Lambda Function Project using Visual Studio through the AWS documentation link provided.

Can you provide an example of an AWS Lambda Function using IronXL?

Yes, the provided code example demonstrates a simple AWS Lambda Function that uses IronXL to create a new Excel workbook and fill cells with labeled values.

What does the example AWS Lambda Function do?

The example AWS Lambda Function takes a string input and processes it using IronXL to create a new Excel workbook, filling cells with labeled values, and returns a Base64 string representation of the Excel file.

Where can I find IronXL NuGet Packages for deployments?

IronXL NuGet Packages for deployments are documented in the IronXL NuGet installation guide.