Skip to content

Commit 8312d79

Browse files
committed
.NET Core 3.1 port
Experimental port to .NET 3.1 (cross-platform)
1 parent 18089ba commit 8312d79

11 files changed

Lines changed: 50 additions & 277 deletions

File tree

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Imagine being able to export the results of a T-SQL query straight into an Excel file. Imagine being able to export the results of an unlimited number of scripts at one time.
44

5-
Well now you can with my free tool sql2xls. The first beta v0.0.1 is available for download from this link. You can export the results of one or more scripts into an Excel file per instance or database.
5+
Well now you can with my free tool *sql2xls*. The latest beta v0.2.0 is available for download from this link. You can export the results of one or more scripts into an Excel file per instance or database.
66

7-
Currently only a .NET Framework 4.7.2 executable exists. In the near future, there will be versions for .NET Core as well.
7+
The latest version runs on .NET Core 3.1. It has been tested on Windows 10 and macOS Catalina.
88

99
## Requirements
1010

11-
- 7-Zip to unpack the compressed file
12-
- .NET Framework 4.7.2 to run the executable
11+
- .NET Core 3.1 SDK to compile and run the executable.
12+
- `mono-libgdiplus` for macOS, or `libgdiplus` for Linux.
1313

1414
## Configuration
1515

@@ -32,20 +32,16 @@ One file is created per database, including the master database.
3232

3333
## Dependencies
3434

35-
- JSON.NET (for parsing config files and SQL Server results)
3635
- ClosedXML (for generating the Excel output)
37-
- Costura.Fody (for generating a single assembly file)
36+
- Microsoft.Data.SqlClient (for connecting to SQL Server)
3837

3938
## Licence
4039

4140
- This project uses the MIT licence.
42-
- Newtonsoft.Json is copyright (c) 2007 James Newton-King
43-
- ClosedXML is copyright (c) 2016 ClosedXML
44-
- Fody.Costura is copyright (c) 2012 Simon Cropp and contributors
41+
- ClosedXML is copyright (c) 2017 ClosedXML
4542

4643
## Future plans
4744

48-
- Cross-platform (Windows, macOS, Linux)
4945
- JSON export
5046
- SQL Server Management Studio plugin
5147

SqlExcelExporter.sln

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,35 @@ VisualStudioVersion = 15.0.28307.438
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlExcelExporter", "SqlExcelExporter\SqlExcelExporter.csproj", "{AEA5090F-E3D0-4B4F-8879-39803FB7517E}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sql2xls", "sql2xls\sql2xls.csproj", "{F9810E81-145A-41AB-8E29-09A0391A49EC}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sql2xls", "sql2xls\sql2xls.csproj", "{A535E2C9-BBD6-4A5B-8121-EFC2EAD3421F}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1212
Debug|Any CPU = Debug|Any CPU
1313
Release|Any CPU = Release|Any CPU
14+
Release.Signed|Any CPU = Release.Signed|Any CPU
1415
EndGlobalSection
1516
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1617
{AEA5090F-E3D0-4B4F-8879-39803FB7517E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1718
{AEA5090F-E3D0-4B4F-8879-39803FB7517E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1819
{AEA5090F-E3D0-4B4F-8879-39803FB7517E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1920
{AEA5090F-E3D0-4B4F-8879-39803FB7517E}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{F9810E81-145A-41AB-8E29-09A0391A49EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{F9810E81-145A-41AB-8E29-09A0391A49EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{F9810E81-145A-41AB-8E29-09A0391A49EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{F9810E81-145A-41AB-8E29-09A0391A49EC}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{AEA5090F-E3D0-4B4F-8879-39803FB7517E}.Release.Signed|Any CPU.ActiveCfg = Debug|Any CPU
22+
{AEA5090F-E3D0-4B4F-8879-39803FB7517E}.Release.Signed|Any CPU.Build.0 = Debug|Any CPU
23+
{A535E2C9-BBD6-4A5B-8121-EFC2EAD3421F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{A535E2C9-BBD6-4A5B-8121-EFC2EAD3421F}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{A535E2C9-BBD6-4A5B-8121-EFC2EAD3421F}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{A535E2C9-BBD6-4A5B-8121-EFC2EAD3421F}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{A535E2C9-BBD6-4A5B-8121-EFC2EAD3421F}.Release.Signed|Any CPU.ActiveCfg = Debug|Any CPU
28+
{A535E2C9-BBD6-4A5B-8121-EFC2EAD3421F}.Release.Signed|Any CPU.Build.0 = Debug|Any CPU
2429
EndGlobalSection
2530
GlobalSection(SolutionProperties) = preSolution
2631
HideSolutionNode = FALSE
2732
EndGlobalSection
2833
GlobalSection(ExtensibilityGlobals) = postSolution
2934
SolutionGuid = {572476B2-2733-4C56-A819-781BBA25E28F}
3035
EndGlobalSection
36+
GlobalSection(MonoDevelopProperties) = preSolution
37+
version = 0.2
38+
EndGlobalSection
3139
EndGlobal

SqlExcelExporter/DatabaseHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Data;
4-
using System.Data.SqlClient;
4+
using Microsoft.Data.SqlClient;
55
using System.Diagnostics;
66
using System.IO;
77
using System.Net.Sockets;

SqlExcelExporter/FileWriter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ public enum FileType
1818
Json
1919
}
2020

21-
private const string PathName = @"C:\Temp";
22-
23-
private List<ResultEntity> m_diagnosticResults;
21+
private readonly List<ResultEntity> m_diagnosticResults;
2422

2523
public List<FileInfo> ProduceExcel()
2624
{
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
</PropertyGroup>
6-
7-
<ItemGroup>
8-
<PackageReference Include="ClosedXML" Version="0.94.2" />
9-
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
10-
<PackageReference Include="System.Data.SqlClient" Version="4.6.0" />
11-
</ItemGroup>
12-
13-
</Project>
3+
<PropertyGroup>
4+
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
5+
<ReleaseVersion>0.2</ReleaseVersion>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.1" />
9+
<PackageReference Include="ClosedXML" Version="0.95.0-beta2" />
10+
</ItemGroup>
11+
</Project>

SqlExcelExporter/Tools.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.IO;
2-
using Newtonsoft.Json;
2+
using System.Text.Json;
33

44
namespace SqlExcelExporter
55
{
@@ -19,10 +19,7 @@ public static T ReadJsonItem<T>(FileInfo file)
1919
return default(T);
2020
}
2121

22-
var deserialiser = new JsonSerializer();
23-
24-
var reader = new JsonTextReader(new StreamReader(file.FullName));
25-
return deserialiser.Deserialize<T>(reader);
22+
return JsonSerializer.Deserialize<T>(File.ReadAllText(file.FullName));
2623
}
2724

2825
/// <summary>

sql2xls/FodyWeavers.xml

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

sql2xls/FodyWeavers.xsd

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

sql2xls/Program.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using Newtonsoft.Json;
54
using SqlExcelExporter;
65

76
namespace SqlToExcelExporter
@@ -13,7 +12,7 @@ class Program
1312

1413
private static void Main()
1514
{
16-
Console.WriteLine("--- SQL to Excel Exporter v0.0.1");
15+
Console.WriteLine("--- SQL to Excel Exporter v0.2.0");
1716
Console.WriteLine("--- Copyright (c) Born SQL");
1817
Console.WriteLine("--- Written by Randolph West and other contributors. https://bornsql.ca/.");
1918
Console.WriteLine();
@@ -28,9 +27,9 @@ private static void Main()
2827
{
2928
m_connectionSettings = Tools.ReadJsonItem<ConnectionEntity>(new FileInfo("connection.json"));
3029
}
31-
catch (JsonReaderException ex)
30+
catch (Exception ex)
3231
{
33-
error = ex.Path;
32+
error = ex.Message;
3433
errorConnection = true;
3534
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] *** ERROR *** An error occurred validating the connection.json file [{error}].");
3635
}
@@ -39,9 +38,9 @@ private static void Main()
3938
{
4039
m_config = Tools.ReadJsonItem<ConfigurationEntity>(new FileInfo(Path.Combine(path, "config.json")));
4140
}
42-
catch (JsonReaderException ex)
41+
catch (Exception ex)
4342
{
44-
error = ex.Path;
43+
error = ex.Message;
4544
errorDiagnostics = true;
4645
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] *** ERROR *** An error occurred validating the config.json file [{error}].");
4746
}

sql2xls/Properties/AssemblyInfo.cs

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

0 commit comments

Comments
 (0)