diff --git a/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs b/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs
index e5401195e..149d69078 100644
--- a/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs
+++ b/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs
@@ -52,7 +52,6 @@ public bool checkExcelDocument()
{
if (Document == null)
{
-#if !NETCORE
if (this.fileName.EndsWith(Constants.EXCEL2003Extension) || this.template.EndsWith(Constants.EXCEL2003ExtensionTemplate))
{
if (document == null || document.ErrCode == 99)
@@ -63,6 +62,7 @@ public bool checkExcelDocument()
document.ReadOnly = ReadOnly;
document.Init(initErrDesc);
}
+#if !NETCORE
if (document == null || document.ErrCode != 0) //Automation
{
GXLogging.Debug(log,"Interop.GXOFFICE2Lib.ExcelDocumentClass");
@@ -70,11 +70,11 @@ public bool checkExcelDocument()
document.ReadOnly = ReadOnly;
document.Init("");
}
- }
- else
#endif
- {
- document = new GeneXus.Office.ExcelGXEPPlus.ExcelDocument();
+ }
+ else
+ {
+ document = new GeneXus.Office.ExcelGXEPPlus.ExcelDocument();
document.ReadOnly = ReadOnly;
}
@@ -437,9 +437,14 @@ public static object GetEnumValue(Assembly ass, string enumSuperClass, string en
return fi.GetValue(null);
}
+ internal static object GetEnumValue(Assembly ass, string enumNameClass, string enumField)
+ {
+ Type prn1 = ass.GetType(enumNameClass);
+ return prn1.GetProperty(enumField).GetValue(null);
+ }
- }
- public interface IGxError
+ }
+ public interface IGxError
{
void setErrCod(short errCod);
void setErrDes(String errDes);
diff --git a/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs b/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs
index a17605cae..59f035170 100644
--- a/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs
+++ b/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs
@@ -6,6 +6,8 @@
using log4net;
using GeneXus.Application;
using GeneXus.Office.Excel;
+using GxClasses.Helpers;
+
namespace GeneXus.Office.ExcelLite
{
@@ -368,7 +370,16 @@ public class ExcelDocument : IGxError, IExcelDocument
{
static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static string nmspace;
+#if NETCORE
+ public static string license = "FREE-LIMITED-KEY";
+ const string LoadMethod = "Load";
+ const string SaveMethod = "Save";
+#else
public static string license;
+ const string LoadMethod = "LoadXls";
+ const string SaveMethod = "SaveXls";
+#endif
+
public static Assembly ass;
public short Init(string previousMsgError)
@@ -381,17 +392,25 @@ public short Init(string previousMsgError)
{
if (nmspace==null)
{
+#if NETCORE
+ ass = AssemblyLoader.LoadAssembly(new AssemblyName("GemBox.Spreadsheet"));
+#else
+
ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), "GemBox.Spreadsheet.dll"));
if (ass==null)
{
ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), "bin", "GemBox.Spreadsheet.dll"));
}
+#endif
if (ass!=null)
{
nmspace="GemBox.Spreadsheet";
}
else
{
+#if NETCORE
+ ass = AssemblyLoader.LoadAssembly(new AssemblyName("GemBox.ExcelLite"));
+#else
if (ass==null)
{
ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), @"GemBox.ExcelLite.dll"));
@@ -400,6 +419,7 @@ public short Init(string previousMsgError)
{
ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), "bin", "GemBox.ExcelLite.dll"));
}
+#endif
if (ass!=null)
{
nmspace="GemBox.ExcelLite";
@@ -409,11 +429,15 @@ public short Init(string previousMsgError)
}
else
{
+#if NETCORE
+ ass = AssemblyLoader.LoadAssembly(new AssemblyName(nmspace));
+#else
ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), nmspace + ".dll"));
if (ass==null)
{
ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), "bin", nmspace + ".dll"));
}
+#endif
}
GXLogging.Debug(log, "nmspace:" + nmspace);
@@ -434,6 +458,7 @@ public short Init(string previousMsgError)
GXLogging.Error(log, @"Error setting license.", e);
}
}
+
}
return 0;
}
@@ -458,7 +483,6 @@ private Assembly loadAssembly(string fileName)
{
return null;
}
-
}
public short Open(String fileName)
{
@@ -479,7 +503,11 @@ public short Open(String fileName)
if (stream != null)
{
stream.Position = 0;
- GxExcelUtils.Invoke(ef, "LoadXls", new object[] { stream });
+#if NETCORE
+ GxExcelUtils.InvokeStatic(ass, classType.FullName, LoadMethod, new object[] { stream });
+#else
+ GxExcelUtils.Invoke(ef, LoadMethod, new object[] { stream });
+#endif
}
}
else
@@ -495,7 +523,12 @@ public short Open(String fileName)
if (stream != null)
{
stream.Position = 0;
- GxExcelUtils.Invoke(ef, "LoadXls", new object[] { stream });
+
+#if NETCORE
+ ef = GxExcelUtils.InvokeStatic(ass, classType.FullName, LoadMethod, new object[] { stream });
+#else
+ GxExcelUtils.Invoke(ef, LoadMethod, new object[] { stream });
+#endif
}
}
else
@@ -523,8 +556,14 @@ public short Save()
{
GxFile file = new GxFile(Path.GetDirectoryName(xlsFileName), xlsFileName, GxFileType.Private);
MemoryStream content = new MemoryStream();
- GxExcelUtils.Invoke(ef, "SaveXls", new object[]{content});
- content.Position = 0;
+
+#if NETCORE
+ object saveOption = GxExcelUtils.GetEnumValue(ExcelDocument.ass, ExcelDocument.nmspace + ".SaveOptions", "XlsDefault");
+ GxExcelUtils.Invoke(ef, SaveMethod, new object[] { content, saveOption });
+#else
+ GxExcelUtils.Invoke(ef, SaveMethod, new object[]{content});
+#endif
+ content.Position = 0;
file.Create(content);
}
catch (Exception e)
diff --git a/dotnet/test/DotNetCoreUnitTest/DotNetCoreUnitTest.csproj b/dotnet/test/DotNetCoreUnitTest/DotNetCoreUnitTest.csproj
index fd4e5ca50..56882bd28 100644
--- a/dotnet/test/DotNetCoreUnitTest/DotNetCoreUnitTest.csproj
+++ b/dotnet/test/DotNetCoreUnitTest/DotNetCoreUnitTest.csproj
@@ -67,12 +67,14 @@
all
+
+
@@ -150,6 +152,9 @@
Always
+
+ PreserveNewest
+
diff --git a/dotnet/test/DotNetCoreUnitTest/Excel/ExcelLiteTest.cs b/dotnet/test/DotNetCoreUnitTest/Excel/ExcelLiteTest.cs
new file mode 100644
index 000000000..91b818cf7
--- /dev/null
+++ b/dotnet/test/DotNetCoreUnitTest/Excel/ExcelLiteTest.cs
@@ -0,0 +1,36 @@
+using System.IO;
+using GeneXus.Office;
+using GeneXus.Utils;
+using UnitTesting;
+using Xunit;
+
+namespace DotNetCoreUnitTest.Excel
+{
+ public class ExcelLiteTest : FileSystemTest
+ {
+ [Fact]
+ public void ExcelLiteReadTest()
+ {
+ ExcelDocumentI excelDocument= new ExcelDocumentI();
+ string fileName = Path.Combine(BaseDir, "SampleXLS.xls");
+ excelDocument.Open(fileName);
+ Assert.Equal(0, excelDocument.ErrCode);
+ double number = excelDocument.get_Cells(2, 1).Number;
+ Assert.Equal(1, number);
+ string text = excelDocument.get_Cells(2, 2).Text;
+ Assert.Equal("A", text);
+
+ number = excelDocument.get_Cells(3, 1).Number;
+ Assert.Equal(2, number);
+ text = excelDocument.get_Cells(3, 2).Text;
+ Assert.Equal("A", text);
+
+ number = excelDocument.get_Cells(101, 1).Number;
+ Assert.Equal(100, number);
+ text = excelDocument.get_Cells(101, 2).Text;
+ Assert.Equal("A", text);
+
+ excelDocument.Close();
+ }
+ }
+}
diff --git a/dotnet/test/DotNetCoreUnitTest/SampleXLS.xls b/dotnet/test/DotNetCoreUnitTest/SampleXLS.xls
new file mode 100644
index 000000000..ef1708f44
Binary files /dev/null and b/dotnet/test/DotNetCoreUnitTest/SampleXLS.xls differ