Skip to content

Commit

Permalink
Edit Excel in Azure V4 Function
Browse files Browse the repository at this point in the history
  • Loading branch information
KonduruKeerthi committed Aug 11, 2023
1 parent bbb21ad commit 86e1a1f
Show file tree
Hide file tree
Showing 14 changed files with 603 additions and 0 deletions.
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.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console_App", "Console_App\Console_App.csproj", "{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C343584F-356A-4748-88A6-D74C362A703F}
EndGlobalSection
EndGlobal
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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>{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Console_App</RootNamespace>
<AssemblyName>Console_App</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="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" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Console_App
{
internal class Program
{
static void Main(string[] args)
{
FileStream excelStream = new FileStream("../../Sample.xlsx", FileMode.Open, FileAccess.Read);
excelStream.Position = 0;

//Saves the Excel document in memory stream.
MemoryStream inputStream = new MemoryStream();
excelStream.CopyTo(inputStream);
inputStream.Position = 0;

try
{
Console.WriteLine("Please enter your Azure Functions URL :");
string functionURL = Console.ReadLine();

//Create HttpWebRequest with hosted azure function URL
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(functionURL);

//Set request method as POST
req.Method = "POST";

//Get the request stream to strore the Excel document stream
Stream stream = req.GetRequestStream();

//Write the Excel document stream into request stream
stream.Write(inputStream.ToArray(), 0, inputStream.ToArray().Length);

//Gets the responce from the Azure Function request
HttpWebResponse res = (HttpWebResponse)req.GetResponse();

//Create file stream to save the output Excel file
FileStream outStream = File.Create("Output.xlsx");

//Copy the responce stream into file stream
res.GetResponseStream().CopyTo(outStream);

//Dispose the input stream
inputStream.Dispose();

//Dispose the file stream
outStream.Dispose();
}
catch (Exception ex)
{
throw;
}
}
}
}
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("Console_App")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Console_App")]
[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("8c8bfc35-5f3f-423b-bb0a-f6eb7a835a2d")]

// 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")]
Binary file not shown.
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.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edit_Excel", "Edit_Excel\Edit_Excel.csproj", "{92BC3291-05A0-4156-8FF8-F5DC86305EE2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{92BC3291-05A0-4156-8FF8-F5DC86305EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92BC3291-05A0-4156-8FF8-F5DC86305EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92BC3291-05A0-4156-8FF8-F5DC86305EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92BC3291-05A0-4156-8FF8-F5DC86305EE2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {984E104E-697B-4C05-9E0B-DB0C63D5AFB5}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 86e1a1f

Please sign in to comment.