Skip to content

Commit

Permalink
Added Concatenate
Browse files Browse the repository at this point in the history
  • Loading branch information
Clouz committed Jul 14, 2018
1 parent 7e0606e commit 78253b6
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 25 deletions.
27 changes: 14 additions & 13 deletions ExcelGenericUDF/ExcelGenericUDF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ExcelDna.Integration, Version=0.33.5730.40390, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExcelDna.Integration.0.33.9\lib\ExcelDna.Integration.dll</HintPath>
<Reference Include="ExcelDna.Integration, Version=0.34.6373.42344, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExcelDna.Integration.0.34.6\lib\ExcelDna.Integration.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ExcelDna.IntelliSense, Version=1.0.0.1547, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExcelDna.IntelliSense.1.0.0\lib\net40\ExcelDna.IntelliSense.dll</HintPath>
<Private>True</Private>
<Reference Include="ExcelDna.IntelliSense, Version=1.1.0.41869, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExcelDna.IntelliSense.1.1.0\lib\net40\ExcelDna.IntelliSense.dll</HintPath>
</Reference>
<Reference Include="Interop.UIAutomationClient, Version=12.0.20617.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\UIAComWrapper.1.1.0.14\lib\net40\Interop.UIAutomationClient.dll</HintPath>
Expand Down Expand Up @@ -70,14 +69,14 @@
<Compile Include="Ribbon.cs" />
<Compile Include="Scheda\Nome.cs" />
<Compile Include="Scheda\Rinomina.cs" />
<Compile Include="Stringa\Concatenate.cs" />
<Compile Include="Stringa\Spazia.cs" />
<Compile Include="Udf.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ExcelGenericUDF-AddIn.dna">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Properties\ExcelDna.Build.props" />
<None Include="ExcelGenericUDF-AddIn.dna" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand All @@ -92,12 +91,14 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna.xll" "$(TargetDir)ExcelGenericUDF-AddIn.xll*" /C /Y
xcopy "$(TargetDir)ExcelGenericUDF-AddIn.dna*" "$(TargetDir)ExcelGenericUDF-AddIn64.dna*" /C /Y
xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna64.xll" "$(TargetDir)ExcelGenericUDF-AddIn64.xll*" /C /Y
"$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDnaPack.exe" "$(TargetDir)ExcelGenericUDF-AddIn.dna" /Y
"$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDnaPack.exe" "$(TargetDir)ExcelGenericUDF-AddIn64.dna" /Y</PostBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Import Project="..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets" Condition="Exists('..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets')" />
<Target Name="EnsureExcelDnaTargetsImported" BeforeTargets="BeforeBuild" Condition="'$(ExcelDnaTargetsImported)' == ''">
<Error Condition="!Exists('..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets') And ('$(RunExcelDnaBuild)' != '' And $(RunExcelDnaBuild))" Text="You are trying to build with ExcelDna, but the NuGet targets file that ExcelDna depends on is not available on this computer. This is probably because the ExcelDna package has not been committed to source control, or NuGet Package Restore is not enabled. Please enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets') And ('$(RunExcelDnaBuild)' != '' And $(RunExcelDnaBuild))" Text="ExcelDna cannot be run because NuGet packages were restored prior to the build running, and the targets file was unavailable when the build started. Please build the project again to include these packages in the build. You may also need to make sure that your build server does not delete packages prior to each build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
48 changes: 48 additions & 0 deletions ExcelGenericUDF/Properties/ExcelDna.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="ExcelDnaProps">
<!--
If you change properties in this file, they may not come into effect until you:
* Rebuild the solution/project
or
* Close Visual Studio
* Delete .vs folder, if exists
* Delete ProjectName.csproj.user (or equivalent for VB, F#, etc.), if exists
* Delete SolutionName.suo, if exists
* Open your solution/project again in Visual Studio
-->

<!--
Configuration properties for building .dna files
-->
<PropertyGroup>
<!--
Enable/Disable automatic generation of platform-specific versions of .dna files
-->
<ExcelDnaCreate32BitAddIn Condition="'$(ExcelDnaCreate32BitAddIn)' == ''">true</ExcelDnaCreate32BitAddIn>
<ExcelDnaCreate64BitAddIn Condition="'$(ExcelDnaCreate64BitAddIn)' == ''">true</ExcelDnaCreate64BitAddIn>

<!--
Define the suffix used for each platform-specific file e.g. MyAddIn64.dna
-->
<ExcelDna32BitAddInSuffix Condition="'$(ExcelDna32BitAddInSuffix)' == ''"></ExcelDna32BitAddInSuffix>
<ExcelDna64BitAddInSuffix Condition="'$(ExcelDna64BitAddInSuffix)' == ''">64</ExcelDna64BitAddInSuffix>
</PropertyGroup>

<!--
Configuration properties for packing .dna files
-->
<PropertyGroup>
<!--
Enable/Disable packing of .dna files
-->
<RunExcelDnaPack Condition="'$(RunExcelDnaPack)' == ''">true</RunExcelDnaPack>

<!--
Suffix used for packed .xll files e.g. MyAddIn-packed.xll
-->
<ExcelDnaPackXllSuffix Condition="'$(ExcelDnaPackXllSuffix)' == ''">-packed</ExcelDnaPackXllSuffix>
</PropertyGroup>
</Project>

44 changes: 44 additions & 0 deletions ExcelGenericUDF/Stringa/Concatenate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ExcelDna.Integration;
using ExcelDna.IntelliSense;

namespace ExcelGenericUDF.Stringa
{
public class Concatenate
{
[ExcelFunction(Name = Udf.nome + ".Stringa.ConcatenateMultiple", Description = "Concatenate adiacent cells")]
public static string ConcatenateMultiple(
[ExcelArgument(Name = "Concatenate Range", Description = "Select multiple cell to concanenate")] object[] Range,
[ExcelArgument(Name = "Separator", Description = "Separator String")] string Separator,
[ExcelArgument(Name = "Include Empty", Description = "if true show empty cells")] bool Empty)
{
try
{
string s = "";

foreach (var cell in Range)
{
if (cell is ExcelEmpty && Empty)
s += "" + Separator;
else if (cell is ExcelEmpty && Empty == false) {

}
else
s += cell + Separator;
}

return s.Substring(0, s.Length - Separator.Length);
}
catch (Exception e)
{
return e.ToString();
}

}
}
}
7 changes: 1 addition & 6 deletions ExcelGenericUDF/Stringa/Spazia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
using ExcelDna.Integration;
using ExcelDna.IntelliSense;

using Excel = Microsoft.Office.Interop.Excel;

namespace ExcelGenericUDF.Stringa
{
public class Spazia
public class Spazia
{

[ExcelFunction(Name = Udf.nome + ".Stringa.Spazia", Description = "Data una stringa ed un pattern ne spazia il contenuto")]
public static string spazia(
[ExcelArgument(Name = "Stringa Iniziale", Description = "")] string nome,
Expand Down Expand Up @@ -57,8 +54,6 @@ public static string spazia(
{
return $"Stringa non corrispondente al pattern: {e.ToString()}";
}

}

}
}
4 changes: 2 additions & 2 deletions ExcelGenericUDF/Udf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class Udf : IExcelAddIn
{
public void AutoOpen()
{
IntelliSenseServer.Register();
IntelliSenseServer.Install();
}

public void AutoClose()
{

IntelliSenseServer.Uninstall();
}

public const string nome = "Claudio";
Expand Down
8 changes: 4 additions & 4 deletions ExcelGenericUDF/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Excel-DNA" version="0.33.9" targetFramework="net452" />
<package id="ExcelDna.AddIn" version="0.33.9" targetFramework="net452" />
<package id="ExcelDna.Integration" version="0.33.9" targetFramework="net452" />
<package id="ExcelDna.IntelliSense" version="1.0.0" targetFramework="net452" />
<package id="Excel-DNA" version="0.34.6" targetFramework="net452" />
<package id="ExcelDna.AddIn" version="0.34.6" targetFramework="net452" />
<package id="ExcelDna.Integration" version="0.34.6" targetFramework="net452" />
<package id="ExcelDna.IntelliSense" version="1.1.0" targetFramework="net452" />
<package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1000" targetFramework="net452" />
<package id="UIAComWrapper" version="1.1.0.14" targetFramework="net452" />
</packages>

0 comments on commit 78253b6

Please sign in to comment.