Skip to content

Commit 977465e

Browse files
authored
Merge pull request #148 from SyncfusionExamples/842222-Loading-Saving-Azure-Windows
842222- Add Sample for Loading and Saving in Azure App Service
2 parents c444146 + c7e4db1 commit 977465e

File tree

233 files changed

+74986
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+74986
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35417.141 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Loading and Saving", "Loading and Saving\Loading and Saving.csproj", "{22857B34-2BC7-40AF-9E76-6901895EBB76}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{22857B34-2BC7-40AF-9E76-6901895EBB76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{22857B34-2BC7-40AF-9E76-6901895EBB76}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{22857B34-2BC7-40AF-9E76-6901895EBB76}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{22857B34-2BC7-40AF-9E76-6901895EBB76}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Diagnostics;
2+
using Loading_and_Saving.Models;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Syncfusion.XlsIO;
5+
6+
namespace Loading_and_Saving.Controllers
7+
{
8+
public class HomeController : Controller
9+
{
10+
private readonly ILogger<HomeController> _logger;
11+
12+
public HomeController(ILogger<HomeController> logger)
13+
{
14+
_logger = logger;
15+
}
16+
17+
public IActionResult Index()
18+
{
19+
return View();
20+
}
21+
public IActionResult LoadingandSaving()
22+
{
23+
//Create an instance of ExcelEngine
24+
using (ExcelEngine excelEngine = new ExcelEngine())
25+
{
26+
IApplication application = excelEngine.Excel;
27+
application.DefaultVersion = ExcelVersion.Xlsx;
28+
29+
//Load an existing Excel document
30+
FileStream inputStream = new FileStream("Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
31+
IWorkbook workbook = application.Workbooks.Open(inputStream);
32+
33+
//Access first worksheet from the workbook.
34+
IWorksheet worksheet = workbook.Worksheets[0];
35+
36+
//Set Text in cell A3.
37+
worksheet.Range["A3"].Text = "Hello World";
38+
39+
//Save the Excel to MemoryStream
40+
MemoryStream outputStream = new MemoryStream();
41+
workbook.SaveAs(outputStream);
42+
43+
//Set the position
44+
outputStream.Position = 0;
45+
46+
//Download the Excel document in the browser.
47+
return File(outputStream, "application/msexcel", "Output.xlsx");
48+
}
49+
}
50+
public IActionResult Privacy()
51+
{
52+
return View();
53+
}
54+
55+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
56+
public IActionResult Error()
57+
{
58+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
59+
}
60+
}
61+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<RootNamespace>Loading_and_Saving</RootNamespace>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="27.1.58" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Data\InputTemplate.xlsx">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Loading_and_Saving.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews();
5+
6+
var app = builder.Build();
7+
8+
// Configure the HTTP request pipeline.
9+
if (!app.Environment.IsDevelopment())
10+
{
11+
app.UseExceptionHandler("/Home/Error");
12+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13+
app.UseHsts();
14+
}
15+
16+
app.UseHttpsRedirection();
17+
app.UseStaticFiles();
18+
19+
app.UseRouting();
20+
21+
app.UseAuthorization();
22+
23+
app.MapControllerRoute(
24+
name: "default",
25+
pattern: "{controller=Home}/{action=Index}/{id?}");
26+
27+
app.Run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
4+
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
5+
-->
6+
<Project>
7+
<PropertyGroup>
8+
<WebPublishMethod>MSDeploy</WebPublishMethod>
9+
<ResourceId>/subscriptions/431b6c0e-6e67-43e0-b169-2a182a91b202/resourcegroups/LoadingandSaving20241107112243/providers/Microsoft.Web/sites/LoadingandSaving20241107112243</ResourceId>
10+
<ResourceGroup>LoadingandSaving20241107112243</ResourceGroup>
11+
<PublishProvider>AzureWebSite</PublishProvider>
12+
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
13+
<LastUsedPlatform>Any CPU</LastUsedPlatform>
14+
<SiteUrlToLaunchAfterPublish>https://loadingandsaving20241107112243.azurewebsites.net</SiteUrlToLaunchAfterPublish>
15+
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
16+
<ExcludeApp_Data>false</ExcludeApp_Data>
17+
<ProjectGuid>22857b34-2bc7-40af-9e76-6901895ebb76</ProjectGuid>
18+
<MSDeployServiceURL>loadingandsaving20241107112243.scm.azurewebsites.net:443</MSDeployServiceURL>
19+
<DeployIisAppPath>LoadingandSaving20241107112243</DeployIisAppPath>
20+
<RemoteSitePhysicalPath />
21+
<SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
22+
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
23+
<EnableMSDeployBackup>true</EnableMSDeployBackup>
24+
<EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
25+
<UserName />
26+
<_SavePWD>false</_SavePWD>
27+
<_DestinationType>AzureWebSite</_DestinationType>
28+
<InstallAspNetCoreSiteExtension>false</InstallAspNetCoreSiteExtension>
29+
</PropertyGroup>
30+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
4+
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
5+
-->
6+
<Project>
7+
<PropertyGroup>
8+
<TimeStampOfAssociatedLegacyPublishXmlFile />
9+
<History>True|2024-11-07T06:10:58.6572264Z||;False|2024-11-07T11:39:48.8259267+05:30||;True|2024-11-07T11:35:27.1749022+05:30||;</History>
10+
<LastFailureDetails />
11+
</PropertyGroup>
12+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_dependencyType": "compute.appService.windows"
6+
},
7+
"parameters": {
8+
"resourceGroupName": {
9+
"type": "string",
10+
"defaultValue": "LoadingandSaving20241107112243",
11+
"metadata": {
12+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
13+
}
14+
},
15+
"resourceGroupLocation": {
16+
"type": "string",
17+
"defaultValue": "eastus",
18+
"metadata": {
19+
"description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
20+
}
21+
},
22+
"resourceName": {
23+
"type": "string",
24+
"defaultValue": "LoadingandSaving20241107112243",
25+
"metadata": {
26+
"description": "Name of the main resource to be created by this template."
27+
}
28+
},
29+
"resourceLocation": {
30+
"type": "string",
31+
"defaultValue": "[parameters('resourceGroupLocation')]",
32+
"metadata": {
33+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
34+
}
35+
}
36+
},
37+
"variables": {
38+
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
39+
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
40+
},
41+
"resources": [
42+
{
43+
"type": "Microsoft.Resources/resourceGroups",
44+
"name": "[parameters('resourceGroupName')]",
45+
"location": "[parameters('resourceGroupLocation')]",
46+
"apiVersion": "2019-10-01"
47+
},
48+
{
49+
"type": "Microsoft.Resources/deployments",
50+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
51+
"resourceGroup": "[parameters('resourceGroupName')]",
52+
"apiVersion": "2019-10-01",
53+
"dependsOn": [
54+
"[parameters('resourceGroupName')]"
55+
],
56+
"properties": {
57+
"mode": "Incremental",
58+
"template": {
59+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
60+
"contentVersion": "1.0.0.0",
61+
"resources": [
62+
{
63+
"location": "[parameters('resourceLocation')]",
64+
"name": "[parameters('resourceName')]",
65+
"type": "Microsoft.Web/sites",
66+
"apiVersion": "2015-08-01",
67+
"tags": {
68+
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
69+
},
70+
"dependsOn": [
71+
"[variables('appServicePlan_ResourceId')]"
72+
],
73+
"kind": "app",
74+
"properties": {
75+
"name": "[parameters('resourceName')]",
76+
"kind": "app",
77+
"httpsOnly": true,
78+
"reserved": false,
79+
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
80+
"siteConfig": {
81+
"metadata": [
82+
{
83+
"name": "CURRENT_STACK",
84+
"value": "dotnetcore"
85+
}
86+
]
87+
}
88+
},
89+
"identity": {
90+
"type": "SystemAssigned"
91+
}
92+
},
93+
{
94+
"location": "[parameters('resourceLocation')]",
95+
"name": "[variables('appServicePlan_name')]",
96+
"type": "Microsoft.Web/serverFarms",
97+
"apiVersion": "2015-08-01",
98+
"sku": {
99+
"name": "S1",
100+
"tier": "Standard",
101+
"family": "S",
102+
"size": "S1"
103+
},
104+
"properties": {
105+
"name": "[variables('appServicePlan_name')]"
106+
}
107+
}
108+
]
109+
}
110+
}
111+
}
112+
]
113+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:17368",
8+
"sslPort": 44305
9+
}
10+
},
11+
"profiles": {
12+
"http": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"applicationUrl": "http://localhost:5146",
17+
"environmentVariables": {
18+
"ASPNETCORE_ENVIRONMENT": "Development"
19+
}
20+
},
21+
"https": {
22+
"commandName": "Project",
23+
"dotnetRunMessages": true,
24+
"launchBrowser": true,
25+
"applicationUrl": "https://localhost:7089;http://localhost:5146",
26+
"environmentVariables": {
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
}
29+
},
30+
"IIS Express": {
31+
"commandName": "IISExpress",
32+
"launchBrowser": true,
33+
"environmentVariables": {
34+
"ASPNETCORE_ENVIRONMENT": "Development"
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)