Skip to content

Commit 430d6a9

Browse files
DYN-8615 UnitTest Import Export XML Excel (#16227)
Now that has two approvals and all checks passed merging to master
1 parent 8711c15 commit 430d6a9

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

test/Libraries/DynamoMSOfficeTests/ExcelTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,5 +1448,32 @@ public static void OpemXML_ImportExcelTest()
14481448
string cellValueWithoutFormula = data[1][2].ToString();
14491449
Assert.AreEqual(cellValueWithFormula, cellValueWithoutFormula);
14501450
}
1451+
1452+
[Test]
1453+
[Category("UnitTests")]
1454+
public static void OpenXML_ImportExcelTestWhenHavingEmptyRow()
1455+
{
1456+
// The spreadsheet OpenXML-ImportExcelEmptyRows contains empty rows
1457+
string filePath = Path.Combine(TestDirectory, @"core\importExport\OpenXML-ImportExcelEmptyRows.xlsx");
1458+
var data = Data.OpenXMLImportExcel(filePath, "Sheet1", 0, 0, false);
1459+
1460+
//Validates that the spreadsheet was imported successfully (not sending any exception)
1461+
Assert.That(data.Length > 0);
1462+
}
1463+
1464+
[Test]
1465+
[Category("UnitTests")]
1466+
public static void OpenXML_ExportExcelTestWhenHavingEmptyRow()
1467+
{
1468+
//The spreadsheet OpenXML-ExportExcelEmptyRows.xlsx contains at the first rows text but later numbers
1469+
string filePath = Path.Combine(TestDirectory, @"core\importExport\OpenXML-ExportExcelEmptyRows.xlsx");
1470+
1471+
//Create a object array with strings (previous was generating a exception this case, when using just numbers the exception was not generated)
1472+
object[][] data = [["21", "22"], ["22", "23"], ["23", "24"], ["24", "25"], ["25", "26"], ["26", "27"], ["27", "28"], ["28", "29"]];
1473+
1474+
//Validates that the data array was successfully inserted to the excel file (not sending any exception)
1475+
var result = Data.OpenXMLExportExcel(filePath, "Sheet1", data, 1, 1);
1476+
Assert.IsTrue(result);
1477+
}
14511478
}
14521479
}
8.25 KB
Binary file not shown.
9.35 KB
Binary file not shown.

0 commit comments

Comments
 (0)