diff --git a/ClassiDiScambio/Celle/CreaID.cs b/ClassiDiScambio/Celle/CreaID.cs new file mode 100644 index 0000000..7285151 --- /dev/null +++ b/ClassiDiScambio/Celle/CreaID.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Excel = Microsoft.Office.Interop.Excel; + + + +namespace ClassiDiScambio.Celle +{ + public class CellID + { + public int Row { get; set; } + public int Column { get; set; } + + + private Excel.Application application; + private Excel.Workbook workbook; + + public CellID(Excel.Application application) + { + this.application = application; + this.workbook = application.ActiveWorkbook; + Excel.Worksheet worksheet = workbook.ActiveSheet; + + Row = application.ActiveCell.Row; + Column = application.ActiveCell.Column; + + Excel.Range range = worksheet.UsedRange.Columns[Column]; + + object[,] colonna = range.get_Value(Excel.XlRangeValueDataType.xlRangeValueDefault); + + int conteggio = 0; + + for (int i = 1; i <= colonna.Length; i++) + { + if (colonna[i,1] is double) + { + if (conteggio < (double)colonna[i, 1]) + { + conteggio = int.Parse(colonna[i, 1].ToString()); + } + } + } + + worksheet.Cells[Row, Column] = conteggio+1; + } + } +} diff --git a/ClassiDiScambio/ClassiDiScambio.csproj b/ClassiDiScambio/ClassiDiScambio.csproj new file mode 100644 index 0000000..f380aa8 --- /dev/null +++ b/ClassiDiScambio/ClassiDiScambio.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {430E6707-F233-4091-8B93-2C2A95BDF03E} + Library + Properties + ClassiDiScambio + ClassiDiScambio + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + True + ..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll + True + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ClassiDiScambio/NumeraFogli/Sheet.cs b/ClassiDiScambio/NumeraFogli/Sheet.cs new file mode 100644 index 0000000..25001b4 --- /dev/null +++ b/ClassiDiScambio/NumeraFogli/Sheet.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Excel = Microsoft.Office.Interop.Excel; + + + +namespace ClassiDiScambio.NumeraFogli +{ + public class ContenutoFogli + { + public int Id { get; set; } + public string Description { get; set; } + public string Value { get; set; } + } + + public class Sheet + { + + public string Cell { get; set; } + + private int _FromSheet; + public int FromSheet + { + get { return this._FromSheet; } + set + { + if (this._FromSheet != value && value <= ToSheet && value > 0) + this._FromSheet = value; + } + } + + private int _ToSheet; + public int ToSheet + { + get { return _ToSheet; } + set { + if (_ToSheet != value && value <= TotalSheet && value >= FromSheet) + _ToSheet = value; + } + } + + public int TotalSheet { get; set; } + + private int _StartingNumber; + public int StartingNumber + { + get { return _StartingNumber; } + set { _StartingNumber = value; } + } + + public int Row { get; set; } + public int Column { get; set; } + + public List contenuto { get; set; } = new List(); + + private Excel.Application application; + private Excel.Workbook workbook; + + + public Sheet(Excel.Application application) + { + this.application = application; + this.workbook = application.ActiveWorkbook; + Excel.Worksheet worksheets = workbook.ActiveSheet; + + Cell = application.ActiveCell.Address; + Row = application.ActiveCell.Row; + Column = application.ActiveCell.Column; + TotalSheet = workbook.Worksheets.Count; + ToSheet = TotalSheet; + FromSheet = worksheets.Index; + StartingNumber = FromSheet; + + ReloadList(); + } + + public void ReloadList() + { + contenuto.Clear(); + + for (int i = 1; i <= ToSheet; i++) + { + Excel.Worksheet worksheets = workbook.Worksheets[i]; + contenuto.Add(new ContenutoFogli() + { + Id = worksheets.Index, + Description = worksheets.Name, + Value = Convert.ToString((worksheets.Cells[Row, Column] as Excel.Range).Value) + }); + } + } + + public void Write() + { + Excel.Workbook workbook = application.ActiveWorkbook; + int num = StartingNumber; + for (int i = FromSheet; i <= ToSheet; i++) + { + Excel.Worksheet worksheets = workbook.Worksheets[i]; + worksheets.Cells[Row, Column] = num++; + } + } + + } +} diff --git a/ClassiDiScambio/Properties/AssemblyInfo.cs b/ClassiDiScambio/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a57ea3f --- /dev/null +++ b/ClassiDiScambio/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Le informazioni generali relative a un assembly sono controllate dal seguente +// set di attributi. Modificare i valori di questi attributi per modificare le informazioni +// associate a un assembly. +[assembly: AssemblyTitle("ClassiDiScambio")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ClassiDiScambio")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili +// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da +// COM, impostare su true l'attributo ComVisible per tale tipo. +[assembly: ComVisible(false)] + +// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi +[assembly: Guid("430e6707-f233-4091-8b93-2c2a95bdf03e")] + +// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: +// +// Versione principale +// Versione secondaria +// Numero di build +// Revisione +// +// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build +// usando l'asterisco '*' come illustrato di seguito: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ClassiDiScambio/packages.config b/ClassiDiScambio/packages.config new file mode 100644 index 0000000..7527161 --- /dev/null +++ b/ClassiDiScambio/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ExcelGenericUDF.sln b/ExcelGenericUDF.sln index d2ee2cb..b54b9b3 100644 --- a/ExcelGenericUDF.sln +++ b/ExcelGenericUDF.sln @@ -1,10 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelGenericUDF", "ExcelGenericUDF\ExcelGenericUDF.csproj", "{3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassiDiScambio", "ClassiDiScambio\ClassiDiScambio.csproj", "{430E6707-F233-4091-8B93-2C2A95BDF03E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelGui", "ExcelGui\ExcelGui.csproj", "{389192F4-B61B-4201-A9F9-C7A4EE725ED2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +19,14 @@ Global {3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {3B9277D4-E48C-42FF-9B44-FDF8817FD0E1}.Release|Any CPU.Build.0 = Release|Any CPU + {430E6707-F233-4091-8B93-2C2A95BDF03E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {430E6707-F233-4091-8B93-2C2A95BDF03E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {430E6707-F233-4091-8B93-2C2A95BDF03E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {430E6707-F233-4091-8B93-2C2A95BDF03E}.Release|Any CPU.Build.0 = Release|Any CPU + {389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {389192F4-B61B-4201-A9F9-C7A4EE725ED2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ExcelGenericUDF/ExcelGenericUDF-AddIn.dna b/ExcelGenericUDF/ExcelGenericUDF-AddIn.dna index f0434dc..1aaa877 100644 --- a/ExcelGenericUDF/ExcelGenericUDF-AddIn.dna +++ b/ExcelGenericUDF/ExcelGenericUDF-AddIn.dna @@ -19,5 +19,5 @@ Excel-DNA also allows the xml for ribbon UI extensions to be specified in the .dna file. See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution. --> - + diff --git a/ExcelGenericUDF/ExcelGenericUDF.csproj b/ExcelGenericUDF/ExcelGenericUDF.csproj index 93cb625..7291e9a 100644 --- a/ExcelGenericUDF/ExcelGenericUDF.csproj +++ b/ExcelGenericUDF/ExcelGenericUDF.csproj @@ -48,8 +48,11 @@ ..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll True + + + @@ -60,9 +63,11 @@ ..\packages\UIAComWrapper.1.1.0.14\lib\net40\UIAComWrapper.dll True + + @@ -75,7 +80,16 @@ - + + + {430e6707-f233-4091-8b93-2c2a95bdf03e} + ClassiDiScambio + + + {389192f4-b61b-4201-a9f9-c7a4ee725ed2} + ExcelGui + + xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna.xll" "$(TargetDir)ExcelGenericUDF-AddIn.xll*" /C /Y diff --git a/ExcelGenericUDF/Ribbon.cs b/ExcelGenericUDF/Ribbon.cs new file mode 100644 index 0000000..dc9e07f --- /dev/null +++ b/ExcelGenericUDF/Ribbon.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +using ExcelDna.Integration; +using ExcelDna.IntelliSense; + +using ExcelDna.Integration.CustomUI; + +using System.Runtime.InteropServices; + + + +using System.Windows.Forms; + +using Excel = Microsoft.Office.Interop.Excel; + +namespace ExcelGenericUDF +{ + [ComVisible(true)] + public class Ribbon : ExcelRibbon + { + + public override string GetCustomUI(string RibbonID) + { + return @" + + + + + + + + + + + + + + + + diff --git a/ExcelGui/NumeraFogli.xaml.cs b/ExcelGui/NumeraFogli.xaml.cs new file mode 100644 index 0000000..b20767a --- /dev/null +++ b/ExcelGui/NumeraFogli.xaml.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +using ClassiDiScambio.NumeraFogli; + + +namespace ExcelGui +{ + /// + /// Logica di interazione per NumeraFogli.xaml + /// + public partial class NumeraFogli : Window + { + Sheet data; + + int _noOfErrorsOnScreen = 0; + + public NumeraFogli(Sheet data) + { + this.data = data; + + InitializeComponent(); + DataContext = this.data; + + ListaPagine.ItemsSource = this.data.contenuto; + } + + private void Esegui_Click(object sender, RoutedEventArgs e) + { + data.Write(); + this.Close(); + } + + private void OnValidationError(object sender, ValidationErrorEventArgs e) + { + if (e.Action == ValidationErrorEventAction.Added) + _noOfErrorsOnScreen++; + else + _noOfErrorsOnScreen--; + + Esegui.IsEnabled = _noOfErrorsOnScreen > 0 ? false : true; + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + + } + } +} diff --git a/ExcelGui/Properties/AssemblyInfo.cs b/ExcelGui/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4ebc433 --- /dev/null +++ b/ExcelGui/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// Le informazioni generali relative a un assembly sono controllate dal seguente +// set di attributi. Modificare i valori di questi attributi per modificare le informazioni +// associate a un assembly. +[assembly: AssemblyTitle("ExcelGui")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ExcelGui")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili +// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da +// COM, impostare su true l'attributo ComVisible per tale tipo. +[assembly: ComVisible(false)] + +//Per iniziare la compilazione delle applicazioni localizzabili, impostare +//CultureYouAreCodingWith nel file .csproj +//all'interno di un . Ad esempio, se si utilizza l'inglese (Stati Uniti) +//nei file di origine, impostare su en-US. Rimuovere quindi il commento dall'attributo +//NeutralResourceLanguage riportato di seguito. Aggiornare "en-US" nella +//riga sottostante in modo che corrisponda all'impostazione UICulture nel file di progetto. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //dove si trovano i dizionari delle risorse specifiche del tema + //(in uso se non è possibile trovare una risorsa nella pagina + // oppure nei dizionari delle risorse dell'applicazione) + ResourceDictionaryLocation.SourceAssembly //dove si trova il dizionario delle risorse generiche + //(in uso se non è possibile trovare una risorsa nella pagina, + // nell'applicazione o nei dizionari delle risorse specifiche del tema) +)] + + +// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: +// +// Versione principale +// Versione secondaria +// Numero di build +// Revisione +// +// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build +// usando l'asterisco '*' come illustrato di seguito: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ExcelGui/Properties/Resources.Designer.cs b/ExcelGui/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b8b654c --- /dev/null +++ b/ExcelGui/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// Versione di runtime:4.0.30319.42000 +// +// Le modifiche apportate a questo file possono causare un comportamento non corretto e andranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace ExcelGui.Properties { + + + /// + /// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via. + /// + // Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder + // tramite uno strumento quale ResGen o Visual Studio. + // Per aggiungere o rimuovere un membro, modificare il file .ResX, quindi eseguire di nuovo ResGen + // con l'opzione /str oppure ricompilare il progetto VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ExcelGui.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte + /// le ricerche di risorse che utilizzano questa classe di risorse fortemente tipizzata. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ExcelGui/Properties/Resources.resx b/ExcelGui/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ExcelGui/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ExcelGui/Properties/Settings.Designer.cs b/ExcelGui/Properties/Settings.Designer.cs new file mode 100644 index 0000000..ec2a61f --- /dev/null +++ b/ExcelGui/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ExcelGui.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ExcelGui/Properties/Settings.settings b/ExcelGui/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/ExcelGui/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file