Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Commit

Permalink
Added NugetPackageTest
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Aug 28, 2017
1 parent 61dc75d commit 80d3d95
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/NugetPackageTest/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/NugetPackageTest.dll",
"args": [],
"cwd": "${workspaceRoot}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
16 changes: 16 additions & 0 deletions src/NugetPackageTest/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/NugetPackageTest.csproj"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}
9 changes: 9 additions & 0 deletions src/NugetPackageTest/NugetPackageTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EPPlus.Core" Version="1.5.2" />
</ItemGroup>
</Project>
74 changes: 74 additions & 0 deletions src/NugetPackageTest/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System.IO;
using OfficeOpenXml;
using OfficeOpenXml.Table;

namespace NugetPackageTest
{
class Program
{
static void Main(string[] args)
{
using (var package = createExcelPackage())
{
package.SaveAs(new FileInfo("report.xlsx"));
}
}

private static ExcelPackage createExcelPackage()
{
var package = new ExcelPackage();
package.Workbook.Properties.Title = "Salary Report";
package.Workbook.Properties.Author = "Vahid N.";
package.Workbook.Properties.Subject = "Salary Report";
package.Workbook.Properties.Keywords = "Salary";


var worksheet = package.Workbook.Worksheets.Add("Employee");

//First add the headers
worksheet.Cells[1, 1].Value = "ID";
worksheet.Cells[1, 2].Value = "Name";
worksheet.Cells[1, 3].Value = "Gender";
worksheet.Cells[1, 4].Value = "Salary (in $)";

//Add values

var numberformat = "#,##0";
var dataCellStyleName = "TableNumber";
var numStyle = package.Workbook.Styles.CreateNamedStyle(dataCellStyleName);
numStyle.Style.Numberformat.Format = numberformat;

worksheet.Cells[2, 1].Value = 1000;
worksheet.Cells[2, 2].Value = "Jon";
worksheet.Cells[2, 3].Value = "M";
worksheet.Cells[2, 4].Value = 5000;
worksheet.Cells[2, 4].Style.Numberformat.Format = numberformat;

worksheet.Cells[3, 1].Value = 1001;
worksheet.Cells[3, 2].Value = "Graham";
worksheet.Cells[3, 3].Value = "M";
worksheet.Cells[3, 4].Value = 10000;
worksheet.Cells[3, 4].Style.Numberformat.Format = numberformat;

worksheet.Cells[4, 1].Value = 1002;
worksheet.Cells[4, 2].Value = "Jenny";
worksheet.Cells[4, 3].Value = "F";
worksheet.Cells[4, 4].Value = 5000;
worksheet.Cells[4, 4].Style.Numberformat.Format = numberformat;

// Add to table / Add summary row
var tbl = worksheet.Tables.Add(new ExcelAddressBase(fromRow: 1, fromCol: 1, toRow: 4, toColumn: 4), "Data");
tbl.ShowHeader = true;
tbl.TableStyle = TableStyles.Dark9;
tbl.ShowTotal = true;
tbl.Columns[3].DataCellStyleName = dataCellStyleName;
tbl.Columns[3].TotalsRowFunction = RowFunctions.Sum;
worksheet.Cells[5, 4].Style.Numberformat.Format = numberformat;

// AutoFitColumns
worksheet.Cells[1, 1, 4, 4].AutoFitColumns();

return package;
}
}
}
Binary file added src/NugetPackageTest/report.xlsx
Binary file not shown.

0 comments on commit 80d3d95

Please sign in to comment.