IronXL 支持使用 .NET Core 的 AWS Lambda 函數

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

IronXL 完全支持用於 .NET Standard Libraries、Core 應用程式、.NET 5 和 .NET 6 項目的 AWS Lambda 函數。

要為Visual Studio添加AWS Toolkit,請按照此連結在 Visual Studio 的 AWS 工具包中使用 AWS Lambda 模板

將 AWS ToolKit 安裝到 Visual Studio 可以讓您創建 AWS Lambda 函數項目。 您可以使用 Visual Studio 學習如何創建 AWS Lambda 函數項目。鏈接

工作中的 AWS Lambda 函數代碼示例

在建立新的 AWS Lambda 函數專案後,您可以嘗試使用這段代碼片段

    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 套件可用於部署記錄於我們的IronXL NuGet 安裝指南.