IronXL-Unterstützung für AWS Lambda-Funktionen mit .NET Core

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

IronXL unterstützt AWS Lambda Function für .NET-Standardbibliotheken, Core-Anwendungen, .NET 5- und .NET 6-Projekte vollständig.

Um AWS ToolKit für Visual Studio hinzuzufügen, folgen Sie diesem LinkVerwendung der AWS Lambda-Vorlagen im AWS Toolkit für Visual Studio

Wenn Sie das AWS ToolKit in Visual Studio installieren, können Sie ein AWS Lambda Function Project erstellen. Hier erfahren Sie, wie Sie ein AWS Lambda-Funktionsprojekt mit Visual Studio erstellen könnenLink

Beispiel für funktionierenden AWS Lambda-Funktionscode

Nach dem Erstellen eines neuen AWS-Lambda-Funktionsprojekts probieren Sie dieses Codeschnipsel aus

    namespace AWSLambdaIronXL
    {
        public class Function
        {

        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public string FunctionHandler(string input, ILambdaContext context)
        {
            WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLS);

            var newSheet = workBook.CreateWorkSheet("new_sheet");
            string ColumnsNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            foreach (char col in ColumnsNames)
            {
                for (int row = 1; row <= 50; row++)
                {
                    var cellName = $"{col}{row}";
                    newSheet [cellName].Value = $"Cell : {cellName}";
                }
            }

            return Convert.ToBase64String( workBook.ToByteArray());
        }
        }
    }
    namespace AWSLambdaIronXL
    {
        public class Function
        {

        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public string FunctionHandler(string input, ILambdaContext context)
        {
            WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLS);

            var newSheet = workBook.CreateWorkSheet("new_sheet");
            string ColumnsNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            foreach (char col in ColumnsNames)
            {
                for (int row = 1; row <= 50; row++)
                {
                    var cellName = $"{col}{row}";
                    newSheet [cellName].Value = $"Cell : {cellName}";
                }
            }

            return Convert.ToBase64String( workBook.ToByteArray());
        }
        }
    }
Namespace AWSLambdaIronXL
		Public Class [Function]

		''' <summary>
		''' A simple function that takes a string and does a ToUpper
		''' </summary>
		''' <param name="input"></param>
		''' <param name="context"></param>
		''' <returns></returns>
		Public Function FunctionHandler(ByVal input As String, ByVal context As ILambdaContext) As String
			Dim workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLS)

			Dim newSheet = workBook.CreateWorkSheet("new_sheet")
			Dim ColumnsNames As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			For Each col As Char In ColumnsNames
				For row As Integer = 1 To 50
					Dim cellName = $"{col}{row}"
					newSheet (cellName).Value = $"Cell : {cellName}"
				Next row
			Next col

			Return Convert.ToBase64String(workBook.ToByteArray())
		End Function
		End Class
End Namespace
VB   C#

IronXL NuGet-Pakete, die für den Einsatz verfügbar sind, werden in unsererIronXL NuGet Installationsanleitung.