Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-5314 Data.OpenXMLImport node is sometimes bringing in Data, sometimes Formulas #13647

Merged
merged 3 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Libraries/DSOffice/OpenXmlHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -228,7 +228,7 @@ internal static bool Write(string filePath, string sheetName, object[][] data, i
currentColumnIndex++;
continue;
}

SetCellValue(data[i][j], cell, sharedStringTable, stylesheet, writeAsString);
currentColumnIndex++;
}
Expand Down Expand Up @@ -396,8 +396,15 @@ private static object GetCellValue(Cell cell, SharedStringTable sharedStringTabl
}
else
{
// Default to raw string value for inline strings and unknown types.
return cell.InnerText;
if (cell.CellFormula == null)
{
// Default to raw string value for inline strings and unknown types.
return cell.InnerText;
}
else
{
return cell.CellValue.Text;
}
}
}

Expand Down
13 changes: 12 additions & 1 deletion test/Libraries/DynamoMSOfficeTests/ExcelTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -1433,5 +1433,16 @@ public void ExportCSVTest()
//Confirm it's correct
Assert.AreEqual(data, Data.ImportCSV(fn));
}

[Test]
[Category("UnitTests")]
public static void OpemXML_ImportExcelTest()
{
string filePath = Path.Combine(TestDirectory, @"core\importExport\OpenXML-ImportExcel.xlsx");
var data = Data.OpenXMLImportExcel(filePath, "worksheet1", 0, 0, false);
string cellValueWithFormula = data[0][2].ToString();
string cellValueWithoutFormula = data[1][2].ToString();
Assert.AreEqual(cellValueWithFormula, cellValueWithoutFormula);
}
}
}
Binary file not shown.