-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e9c6f2
commit b9cbd0d
Showing
13 changed files
with
368 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.33516.290 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EditExcel", "EditExcel\EditExcel.csproj", "{310E60FE-70C2-484E-B06B-E2C56A1FF754}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{310E60FE-70C2-484E-B06B-E2C56A1FF754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{310E60FE-70C2-484E-B06B-E2C56A1FF754}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{310E60FE-70C2-484E-B06B-E2C56A1FF754}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{310E60FE-70C2-484E-B06B-E2C56A1FF754}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {7E41C673-8721-4777-B667-1C9A185E1AC1} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+217 KB
Getting Started/AWS/AWS Lambda/Edit Excel/EditExcel/Data/InputTemplate.xlsx
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
Getting Started/AWS/AWS Lambda/Edit Excel/EditExcel/EditExcel.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | ||
<AWSProjectType>Lambda</AWSProjectType> | ||
<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. --> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<!-- Generate ready to run images during publishing to improve cold start time. --> | ||
<PublishReadyToRun>true</PublishReadyToRun> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> | ||
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" /> | ||
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="23.1.41" /> | ||
</ItemGroup> | ||
</Project> |
48 changes: 48 additions & 0 deletions
48
Getting Started/AWS/AWS Lambda/Edit Excel/EditExcel/Function.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Amazon.Lambda.Core; | ||
using Syncfusion.XlsIO; | ||
using System.Reflection.Metadata; | ||
using static System.Net.Mime.MediaTypeNames; | ||
|
||
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. | ||
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] | ||
|
||
namespace EditExcel; | ||
|
||
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) | ||
{ | ||
//New instance of ExcelEngine is created | ||
//Equivalent to launching Microsoft Excel with no workbooks open | ||
//Instantiate the spreadsheet creation engine | ||
ExcelEngine excelEngine = new ExcelEngine(); | ||
|
||
//Instantiate the Excel application object | ||
IApplication application = excelEngine.Excel; | ||
|
||
//Assigns default application version | ||
application.DefaultVersion = ExcelVersion.Xlsx; | ||
|
||
//A existing workbook is opened. | ||
FileStream sampleFile = new FileStream(@"Data/InputTemplate.xlsx", FileMode.Open); | ||
IWorkbook workbook = application.Workbooks.Open(sampleFile); | ||
|
||
//Access first worksheet from the workbook. | ||
IWorksheet worksheet = workbook.Worksheets[0]; | ||
|
||
//Set Text in cell A3. | ||
worksheet.Range["A3"].Text = "Hello World"; | ||
|
||
//Creating stream object. | ||
MemoryStream stream = new MemoryStream(); | ||
workbook.SaveAs(stream); | ||
return Convert.ToBase64String(stream.ToArray()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Getting Started/AWS/AWS Lambda/Edit Excel/EditExcel/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"profiles": { | ||
"Mock Lambda Test Tool": { | ||
"commandName": "Executable", | ||
"commandLineArgs": "--port 5050", | ||
"workingDirectory": ".\\bin\\$(Configuration)\\net6.0", | ||
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-6.0.exe" | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Getting Started/AWS/AWS Lambda/Edit Excel/EditExcel/Readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# AWS Lambda Empty Function Project | ||
|
||
This starter project consists of: | ||
* Function.cs - class file containing a class with a single function handler method | ||
* aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS | ||
|
||
You may also have a test project depending on the options selected. | ||
|
||
The generated function handler is a simple method accepting a string argument that returns the uppercase equivalent of the input string. Replace the body of this method, and parameters, to suit your needs. | ||
|
||
## Here are some steps to follow from Visual Studio: | ||
|
||
To deploy your function to AWS Lambda, right click the project in Solution Explorer and select *Publish to AWS Lambda*. | ||
|
||
To view your deployed function open its Function View window by double-clicking the function name shown beneath the AWS Lambda node in the AWS Explorer tree. | ||
|
||
To perform testing against your deployed function use the Test Invoke tab in the opened Function View window. | ||
|
||
To configure event sources for your deployed function, for example to have your function invoked when an object is created in an Amazon S3 bucket, use the Event Sources tab in the opened Function View window. | ||
|
||
To update the runtime configuration of your deployed function use the Configuration tab in the opened Function View window. | ||
|
||
To view execution logs of invocations of your function use the Logs tab in the opened Function View window. | ||
|
||
## Here are some steps to follow to get started from the command line: | ||
|
||
Once you have edited your template and code you can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line. | ||
|
||
Install Amazon.Lambda.Tools Global Tools if not already installed. | ||
``` | ||
dotnet tool install -g Amazon.Lambda.Tools | ||
``` | ||
|
||
If already installed check if new version is available. | ||
``` | ||
dotnet tool update -g Amazon.Lambda.Tools | ||
``` | ||
|
||
Execute unit tests | ||
``` | ||
cd "EditExcel/test/EditExcel.Tests" | ||
dotnet test | ||
``` | ||
|
||
Deploy function to AWS Lambda | ||
``` | ||
cd "EditExcel/src/EditExcel" | ||
dotnet lambda deploy-function | ||
``` |
27 changes: 27 additions & 0 deletions
27
Getting Started/AWS/AWS Lambda/Edit Excel/EditExcel/aws-lambda-tools-defaults.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
{ | ||
"Information" : [ | ||
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", | ||
"To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", | ||
"dotnet lambda help", | ||
"All the command line options for the Lambda command can be specified in this file." | ||
], | ||
"profile" : "default", | ||
"region" : "us-east-1", | ||
"configuration" : "Release", | ||
"function-architecture" : "x86_64", | ||
"function-runtime" : "dotnet6", | ||
"function-memory-size" : 256, | ||
"function-timeout" : 30, | ||
"function-handler" : "EditExcel::EditExcel.Function::FunctionHandler", | ||
"framework" : "net6.0", | ||
"function-name" : "MynewFunction", | ||
"package-type" : "Zip", | ||
"function-role" : "arn:aws:iam::142887710098:role/ck_lambda_basic_execution", | ||
"function-subnets" : "", | ||
"function-security-groups" : "", | ||
"tracing-mode" : "PassThrough", | ||
"environment-variables" : "", | ||
"image-tag" : "", | ||
"function-description" : "" | ||
} |
25 changes: 25 additions & 0 deletions
25
Getting Started/AWS/Console Application/Edit Excel/EditExcel.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.33516.290 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditExcel", "EditExcel\EditExcel.csproj", "{671F927A-08A1-4F27-BF27-036E65065674}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{671F927A-08A1-4F27-BF27-036E65065674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{671F927A-08A1-4F27-BF27-036E65065674}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{671F927A-08A1-4F27-BF27-036E65065674}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{671F927A-08A1-4F27-BF27-036E65065674}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {6328D5EF-5161-4BDC-9075-F7FA6676146E} | ||
EndGlobalSection | ||
EndGlobal |
6 changes: 6 additions & 0 deletions
6
Getting Started/AWS/Console Application/Edit Excel/EditExcel/App.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
67 changes: 67 additions & 0 deletions
67
Getting Started/AWS/Console Application/Edit Excel/EditExcel/EditExcel.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{671F927A-08A1-4F27-BF27-036E65065674}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>EditExcel</RootNamespace> | ||
<AssemblyName>EditExcel</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\AWSSDK.Core.3.7.204.2\lib\net45\AWSSDK.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="AWSSDK.Lambda, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\AWSSDK.Lambda.3.7.202.1\lib\net45\AWSSDK.Lambda.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Analyzer Include="..\packages\AWSSDK.Lambda.3.7.202.1\analyzers\dotnet\cs\AWSSDK.Lambda.CodeAnalysis.dll" /> | ||
<Analyzer Include="..\packages\AWSSDK.Lambda.3.7.202.1\analyzers\dotnet\cs\SharedAnalysisCode.dll" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
51 changes: 51 additions & 0 deletions
51
Getting Started/AWS/Console Application/Edit Excel/EditExcel/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Amazon; | ||
using Amazon.Lambda; | ||
using Amazon.Lambda.Model; | ||
using Newtonsoft.Json; | ||
|
||
namespace EditExcel | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Please enter your AWS Access Key ID :"); | ||
string awsAccessKeyID = Console.ReadLine(); | ||
Console.WriteLine("Please enter your AWS Secret Access Key :"); | ||
string awsSecretAccessKey = Console.ReadLine(); | ||
Console.WriteLine("Please enter your Function Name :"); | ||
string functionName = Console.ReadLine(); | ||
//Create a new AmazonLambdaClient | ||
AmazonLambdaClient client = new AmazonLambdaClient(awsAccessKeyID, awsSecretAccessKey, RegionEndpoint.USEast1); | ||
|
||
//Create new InvokeRequest with published function name. | ||
InvokeRequest invoke = new InvokeRequest | ||
{ | ||
FunctionName = functionName, | ||
InvocationType = InvocationType.RequestResponse, | ||
Payload = "\"Test\"" | ||
}; | ||
//Get the InvokeResponse from client InvokeRequest. | ||
InvokeResponse response = client.Invoke(invoke); | ||
|
||
//Read the response stream | ||
var stream = new StreamReader(response.Payload); | ||
JsonReader reader = new JsonTextReader(stream); | ||
var serilizer = new JsonSerializer(); | ||
var responseText = serilizer.Deserialize(reader); | ||
//Convert Base64String into PDF document | ||
byte[] bytes = Convert.FromBase64String(responseText.ToString()); | ||
FileStream fileStream = new FileStream("Sample.xlsx", FileMode.Create); | ||
BinaryWriter writer = new BinaryWriter(fileStream); | ||
writer.Write(bytes, 0, bytes.Length); | ||
writer.Close(); | ||
System.Diagnostics.Process.Start("Sample.xlsx"); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Getting Started/AWS/Console Application/Edit Excel/EditExcel/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("EditExcel")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("EditExcel")] | ||
[assembly: AssemblyCopyright("Copyright © 2023")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("671f927a-08a1-4f27-bf27-036e65065674")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
6 changes: 6 additions & 0 deletions
6
Getting Started/AWS/Console Application/Edit Excel/EditExcel/packages.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="AWSSDK.Core" version="3.7.204.2" targetFramework="net472" /> | ||
<package id="AWSSDK.Lambda" version="3.7.202.1" targetFramework="net472" /> | ||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" /> | ||
</packages> |