This repository has been archived by the owner on Jan 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Showing
5 changed files
with
127 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,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}" | ||
} | ||
] | ||
} |
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,16 @@ | ||
{ | ||
"version": "0.1.0", | ||
"command": "dotnet", | ||
"isShellCommand": true, | ||
"args": [], | ||
"tasks": [ | ||
{ | ||
"taskName": "build", | ||
"args": [ | ||
"${workspaceRoot}/NugetPackageTest.csproj" | ||
], | ||
"isBuildCommand": true, | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
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,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> |
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,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 not shown.