From 2c7a1364150693128d521e5655eb2e3a3c42ae33 Mon Sep 17 00:00:00 2001 From: marcello Date: Sun, 6 Dec 2020 04:08:34 +0100 Subject: [PATCH] first commit --- .gitattributes | 63 ++++++++ .gitignore | 340 +++++++++++++++++++++++++++++++++++++++ Program.cs | 80 ++++++++++ appsettings.json | 3 + ranx.csproj | 30 ++++ ranx.sln | 31 ++++ ranxlib/ExcelHelper.cs | 353 +++++++++++++++++++++++++++++++++++++++++ ranxlib/ranxlib.csproj | 13 ++ 8 files changed, 913 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Program.cs create mode 100644 appsettings.json create mode 100644 ranx.csproj create mode 100644 ranx.sln create mode 100644 ranxlib/ExcelHelper.cs create mode 100644 ranxlib/ranxlib.csproj diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ce6fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,340 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..f4541f1 --- /dev/null +++ b/Program.cs @@ -0,0 +1,80 @@ +using Microsoft.Extensions.Configuration; +using ranxlib; +using System; +using System.Collections; +using System.Data; +using System.Data.SqlClient; + +namespace ranx +{ + class Program + { + static void Main(string[] args) + { + //var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + var builder = new ConfigurationBuilder() + .AddJsonFile($"appsettings.json", true, true) + //.AddJsonFile($"appsettings.{env}.json", true, true) + .AddEnvironmentVariables(); + + var config = builder.Build(); + + Console.WriteLine("Test addRowTotal"); + TestAddRowTotal(config); + + Console.ReadLine(); + + } + + public static void TestAddRowTotal(IConfigurationRoot config) + { + string sql = @"SELECT TOP 10 + ProductName + ,sum(quantity) as Bottles_sold + ,sum(ExtendedPrice) as Subtotal_per_Wine + FROM [dbo].[Order Details Extended] + group by ProductName ORDER BY sum(ExtendedPrice) DESC"; + var results = GetDataTable(config, sql, null); + + var file = AppDomain.CurrentDomain.BaseDirectory + "/output/rowtotal.xlsx"; + ExcelHelper eh = ExcelHelper.Create(file); + eh.Dump(results, "SHEET1"); + eh.AddRowTotal("SHEET1"); + //eh.DoPivotTable("SHEET1", "SHEET2", new string[]{"ProductName"}, new string[] {"Subtotal_per_Wine" }); + eh.Save(); + eh.Dispose(); + Console.WriteLine("file created in " + file); + Console.WriteLine("End testAddRowTotal"); + } + + public static DataTable GetDataTable(IConfigurationRoot config, string sql, Hashtable _params = null) + { + //Console.WriteLine(config["ConnectionString"]); + SqlConnection conn = new SqlConnection(config["ConnectionString"]); + DataTable result = new DataTable(); + SqlCommand cmd = null; + try + { + cmd = new SqlCommand(sql, conn); + cmd.Connection.Open(); + if (_params != null) + { + + } + SqlDataReader reader = cmd.ExecuteReader(); + result.Load(reader); + reader.Close(); + cmd.Connection.Close(); + } + catch(Exception ex) + { + Console.WriteLine(ex.Message); + cmd.Connection.Close(); + } + + + return result; + } + + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..132d2eb --- /dev/null +++ b/appsettings.json @@ -0,0 +1,3 @@ +{ + "ConnectionString": "Server=PC-NUOVO;Database=NorthWind;Trusted_Connection=True;MultipleActiveResultSets=true;Connection Timeout=60" +} \ No newline at end of file diff --git a/ranx.csproj b/ranx.csproj new file mode 100644 index 0000000..b43ec47 --- /dev/null +++ b/ranx.csproj @@ -0,0 +1,30 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + + PreserveNewest + + + + + + + + + + + + + + + diff --git a/ranx.sln b/ranx.sln new file mode 100644 index 0000000..234559b --- /dev/null +++ b/ranx.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ranx", "ranx.csproj", "{F50960EE-C944-4D86-8683-CE88D040C716}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ranxlib", ".\ranxlib\ranxlib.csproj", "{F86A9BBB-09E7-481A-9682-37B7B53F220C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F50960EE-C944-4D86-8683-CE88D040C716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F50960EE-C944-4D86-8683-CE88D040C716}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F50960EE-C944-4D86-8683-CE88D040C716}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F50960EE-C944-4D86-8683-CE88D040C716}.Release|Any CPU.Build.0 = Release|Any CPU + {F86A9BBB-09E7-481A-9682-37B7B53F220C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F86A9BBB-09E7-481A-9682-37B7B53F220C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F86A9BBB-09E7-481A-9682-37B7B53F220C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F86A9BBB-09E7-481A-9682-37B7B53F220C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EAF5C119-BDF7-48AF-8643-93F185CD31F7} + EndGlobalSection +EndGlobal diff --git a/ranxlib/ExcelHelper.cs b/ranxlib/ExcelHelper.cs new file mode 100644 index 0000000..8c1a38c --- /dev/null +++ b/ranxlib/ExcelHelper.cs @@ -0,0 +1,353 @@ +using ClosedXML.Excel; +using System; +using System.IO; + +namespace ranxlib +{ + public class ExcelHelper : IDisposable + { + protected FileInfo _inputFile = null; + protected XLWorkbook _workbook; + protected string _defaultSummarySheetName = "SUMMARY"; + protected SaveOptions _defaultSaveOptions = null; + + /// + /// ''' Apre file "inputFile" + /// ''' + /// ''' percorso a file excel + /// ''' + public static ExcelHelper Create(string inputFile, bool mustExists = false, string summarySheetName = "SUMMARY") + { + return new ExcelHelper(inputFile, mustExists, summarySheetName); + } + protected void _CreateFile(string inputFile) + { + this._workbook = new XLWorkbook(XLEventTracking.Disabled); + + var worksheet = this._CreateSummary(); + + _workbook.SaveAs(inputFile); + _workbook.Dispose(); + } + protected IXLWorksheet _CreateSummary() + { + var worksheet = _workbook.Worksheets.Add(this._defaultSummarySheetName); + worksheet.ActiveCell = worksheet.Cell(1, 10); + worksheet.ActiveCell.Value = this._defaultSummarySheetName; + worksheet.ActiveCell.Style.Font.Bold = true; + return worksheet; + } + public ExcelHelper RemoveSummary() + { + this.RemoveSheet(this._defaultSummarySheetName); + return this; + } + protected void RemoveSheet(string sheetName) + { + try + { + IXLWorksheet sheet = this._workbook.Worksheet(sheetName); + if (sheet != null) + { + _workbook.Worksheets.Delete(sheet.Name); + } + + } + catch (Exception ex) + { + //SD.Log(ex.Message, SD.LogLevel.Warning, ex.StackTrace); + } + } + protected ExcelHelper(string inputFile, bool mustExists = false, string summarySheetName = "SUMMARY") + { + + this._defaultSummarySheetName = summarySheetName; + this._defaultSaveOptions = new SaveOptions(); + _defaultSaveOptions.EvaluateFormulasBeforeSaving = false; + _defaultSaveOptions.ValidatePackage = false; + bool fileExists = File.Exists(inputFile); + if (fileExists == false & mustExists == true) + throw new Exception("File " + inputFile + " not Found"); + else if (fileExists == false & mustExists == false) + { + try + { + this._CreateFile(inputFile); + this._workbook = new XLWorkbook(XLEventTracking.Disabled); + } + catch (Exception ex) + { + + //SD.Log(ex.Message + " " + ex.Source, SD.LogLevel.Error, ex.StackTrace); + return; + } + } + else if (fileExists == true) + { + try + { + this._workbook = new XLWorkbook(XLEventTracking.Disabled); + } + catch (Exception ex) + { + //SD.Log(ex.Message, SD.LogLevel.Error, ex.StackTrace); + } + } + this._inputFile = new FileInfo(inputFile); + } + /// + /// ''' Le datatable devono avere .Name=nome del worksheet per questo controllo prima se esiste già e lo cancello + /// ''' + /// ''' + /// ''' + /// ''' + public ExcelHelper Dump(System.Data.DataTable records, string workSheetName, bool forceWSheetRecreate = false) + { + this.RemoveSheet(workSheetName); + this._workbook.Worksheets.Add(records, workSheetName); + + return this; + } + /// + /// ''' can't touch already created pivot-table + /// ''' https://github.com/ClosedXML/ClosedXML/pull/124 + /// ''' + /// ''' + /// ''' + /// ''' + /// ''' + /// ''' + public ExcelHelper DoPivotTable(string sheetSource, string sheetDest, string[] rows = null, string[] cols = null, string[] datafields = null) + { + try + { + IXLWorksheet worksheetSource = null; + IXLTable sourceTable = null; + + if (_workbook.Worksheets.Count < 1) + { + _workbook = new XLWorkbook(this._inputFile.FullName); + } + worksheetSource = _workbook.Worksheets.Worksheet(sheetSource); + sourceTable = worksheetSource.Table(0); + // TODO PRIMA CONTROLLARE SE ESISTE E nel caso cancella + this.RemoveSheet(sheetDest); // < + /// ''' TOD: studiare https://github.com/ClosedXML/ClosedXML/wiki/Using-Formulas + /// ''' + /// ''' + /// ''' + /// ''' + /// ''' + public ExcelHelper AddFormula(string sheetName, IXLAddress cellAddress, string formula) + { + try + { + IXLWorksheet ActiveWorkSheet = this._workbook.Worksheets.Worksheet(sheetName); + IXLCell ActiveCell = ActiveWorkSheet.Cell(cellAddress); + ActiveCell.FormulaA1 = formula; + } + // _workbook.CalculateMode = autoCalc + catch (Exception ex) + { + // SD.Log(ex.Message, SD.LogLevel.Error, ex.StackTrace); + } + + + return this; + } + /// + /// ''' TODO AGGIUNGERE PARAMETRO ROUNDING OPPURE CELLFORMAT + /// ''' + /// ''' + /// ''' + /// ''' + /// ''' + /// ''' + public ExcelHelper AddRowTotal(string sheetName, string labelCell = "A", string labelCellValue = "TOT.", bool excludeHeaders = true) + { + IXLRange range = this.GetRangeUsed(sheetName); + if (range == null) + { + //SD.Log("range not found in " + sheetName, SD.LogLevel.Error); + return this; + } + int rowsNumber = range.RowCount(); + IXLCell lastCellUsed = range.LastCellUsed(); + IXLColumn lastColUsed = lastCellUsed.WorksheetColumn(); + IXLRow lastRowUsed = lastCellUsed.WorksheetRow(); + string lastColLetter = lastColUsed.ColumnLetter(); + int lastRowNumber = lastRowUsed.RowNumber(); + IXLRows rows = lastRowUsed.InsertRowsBelow(1); + //IXLRow newRow = rows.Last(); + var ws = this._workbook.Worksheets.Worksheet(sheetName); + IXLRow newRow = ws.LastRowUsed().RowBelow(); + + if (labelCell.Trim() != "") + { + newRow.Cell(labelCell).Value = labelCellValue; + newRow.Cell(labelCell).Style.Font.Bold = true; + } + var firstTotalCellAddress = newRow.FirstCell().CellRight().Address; + var lastTotalCellAddress = newRow.Cell(lastColLetter).Address; + IXLRange rangeTotal = this.GetRangeUsed(sheetName, firstTotalCellAddress, lastTotalCellAddress); + //int i = rangeTotal.Cells().Count() + 1; + int i = rangeTotal.ColumnCount() + 1; + int firstDataRowIndex = 0; + // escludo la riga delle intestazioni + if (excludeHeaders) + { + firstDataRowIndex = 2; + } + + for (int k = 1; k <= i; k++) + { + XLDataType colDataType = newRow.Cell(k).CellAbove(1).DataType; + if (colDataType == XLDataType.Number) + { + string colLetter = newRow.Cell(k).Address.ColumnLetter; + string formula = "=SUM(" + colLetter + firstDataRowIndex.ToString() + ":" + colLetter + rowsNumber.ToString() + ")"; + this.AddFormula(sheetName, newRow.Cell(k).Address, formula); + } + } + newRow.AsRange().RangeUsed().Style.Border.TopBorder = XLBorderStyleValues.Thick; + return this; + } + public IXLRange GetRangeUsed(string sheetName, IXLAddress startAddress, IXLAddress endAddress) + { + IXLRange range = null/* TODO Change to default(_) if this is not a reference type */; + if (_workbook.Worksheets.Count < 1) + _workbook = new XLWorkbook(this._inputFile.FullName); + try + { + var sheet = this._workbook.Worksheets.Worksheet(sheetName); + range = this._workbook.Worksheets.Worksheet(sheetName).Range(startAddress, endAddress); + } + catch (Exception ex) + { + //SD.Log(ex.Message, SD.LogLevel.Error, ex.StackTrace); + } + + return range; + } + public IXLRange GetRangeUsed(string sheetName) + { + IXLRange range = null; + if (_workbook.Worksheets.Count < 1) + _workbook = new XLWorkbook(this._inputFile.FullName); + try + { + range = this._workbook.Worksheets.Worksheet(sheetName).RangeUsed(); + } + catch (Exception ex) + { + //SD.Log("sheet " + sheetName + " not found", SD.LogLevel.Error, ex.StackTrace); + } + + return range; + } + public ExcelHelper Save(SaveOptions options = null) + { + try + { + if (options == null) + { + options = this._defaultSaveOptions; + } + this._workbook.SaveAs(this._inputFile.FullName, options); + } + catch (Exception ex) + { + //SD.Log(ex.Message, SD.LogLevel.Error, ex.StackTrace); + throw; + } + + return this; + } + public void SaveAsStream(ref Stream stream, SaveOptions options = null) + { + try + { + if (options == null) + options = this._defaultSaveOptions; + this._workbook.SaveAs(stream, options); + } + catch (Exception ex) + { + //SD.Log(ex.Message, SD.LogLevel.Error, ex.StackTrace); + throw; + } + } + + private bool disposedValue; // Per rilevare chiamate ridondanti + + // IDisposable + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + // TODO: eliminare lo stato gestito (oggetti gestiti). + this._workbook.Dispose(); + } + disposedValue = true; + } + + + // Questo codice viene aggiunto da c# per implementare in modo corretto il criterio Disposable. + public void Dispose() + { + // Non modificare questo codice. Inserire sopra il codice di pulizia in Dispose(disposing As Boolean). + Dispose(true); + } + } +} diff --git a/ranxlib/ranxlib.csproj b/ranxlib/ranxlib.csproj new file mode 100644 index 0000000..02fdd7b --- /dev/null +++ b/ranxlib/ranxlib.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp3.1 + + + + + + + + +