Skip to content

Commit d0606c4

Browse files
committed
Triggering excel on github actions runner
1 parent 6fbeb2d commit d0606c4

File tree

4 files changed

+40
-27
lines changed

4 files changed

+40
-27
lines changed

GithubActionsHelloWorld/AssemblyInfo.cs

Lines changed: 0 additions & 3 deletions
This file was deleted.

GithubActionsHelloWorld/GithubActionsHelloWorld.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net48</TargetFramework>
66
<Version Condition="'$(CURRENT_VERSION)' != ''">$(CURRENT_VERSION)</Version>
77
<Version Condition="'$(CURRENT_VERSION)' == ''">0.0.1</Version>
88
<AssemblyVersion>$(Version)</AssemblyVersion>
@@ -15,13 +15,11 @@
1515
<PackageId>GithubActionsHelloWorld</PackageId>
1616
<PackageReleaseNotes>$(LAST_COMMIT_MESSAGE)</PackageReleaseNotes>
1717
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
18-
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1918
</PropertyGroup>
2019

2120
<ItemGroup>
22-
<PackageReference Include="GitInfo" Version="2.2.0" />
23-
<PackageReference Include="SixLabors.ImageSharp" Version="2.0.0" />
24-
<PackageReference Include="ZXing.Net" Version="0.16.8" />
21+
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
22+
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1003" />
2523
</ItemGroup>
2624

2725
</Project>

GithubActionsHelloWorld/Program.cs

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
1-
using SixLabors.ImageSharp;
2-
using SixLabors.ImageSharp.PixelFormats;
1+
using Microsoft.Office.Interop.Excel;
2+
using System;
3+
using System.IO;
4+
using System.Runtime.InteropServices;
35
using System.Threading.Tasks;
4-
using ZXing.Common;
5-
using ZXing.Rendering;
66

77
namespace GithubActionsHelloWorld
88
{
99
public class Program
1010
{
1111
public static async Task Main(string[] args)
1212
{
13-
var barcodeWriter = new ZXing.BarcodeWriterPixelData
13+
CreateExcelDocument();
14+
}
15+
16+
private static void CreateExcelDocument()
17+
{
18+
Microsoft.Office.Interop.Excel.Application excelApplication = null;
19+
20+
try
1421
{
15-
Format = ZXing.BarcodeFormat.CODE_128,
16-
Options = new EncodingOptions
17-
{
18-
Height = 300,
19-
Width = 300,
20-
},
21-
Renderer = new PixelDataRenderer
22+
excelApplication = new
23+
Microsoft.Office.Interop.Excel.Application();
24+
Workbook excelWorkBook = excelApplication.Workbooks.Add();
25+
Worksheet worksheet = (Worksheet)excelWorkBook.Worksheets[1];
26+
worksheet.Cells[1, 1] = "Product Id";
27+
worksheet.Cells[1, 2] = "Product Name";
28+
worksheet.Cells[2, 1] = "1";
29+
worksheet.Cells[2, 2] = "Lenovo Laptop";
30+
worksheet.Cells[3, 1] = "2";
31+
worksheet.Cells[3, 2] = "DELL Laptop";
32+
var path = Path.GetTempFileName() + ".xlsx";
33+
Console.WriteLine(path);
34+
excelWorkBook.SaveAs(Path.Combine(path));
35+
}
36+
catch (Exception ex)
37+
{
38+
Console.WriteLine(ex.Message);
39+
}
40+
finally
41+
{
42+
if (excelApplication != null)
2243
{
44+
excelApplication.Quit();
45+
Marshal.FinalReleaseComObject(excelApplication);
2346
}
24-
};
25-
26-
var pixelData = barcodeWriter.Write("Hallo Barcode");
27-
28-
using (var image = Image.LoadPixelData<Rgba32>(pixelData.Pixels, 300, 300))
29-
await image.SaveAsBmpAsync("barcode.bmp");
47+
}
3048
}
3149
}
3250
}

GithubActionsHelloWorldTests/GithubActionsHelloWorldTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net48</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

0 commit comments

Comments
 (0)