Skip to content

Commit 49ea78b

Browse files
committed
Upgrade Open XML SDK to version 3.2.0
- Updated Open XML SDK dependency to 3.2.0 for improved performance and compatibility. - Refactored code to handle changes in DataValidationValues and related APIs. - Enhanced error handling for unsupported or new validation types introduced in Open XML documents. - Adjusted unit tests to ensure compatibility with the updated SDK version.
1 parent 631e5af commit 49ea78b

File tree

6 files changed

+15
-20
lines changed

6 files changed

+15
-20
lines changed

CLA.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

FileFormat.Cells/FileFormat.Cells.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222

2323

2424
<ItemGroup>
25-
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
25+
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
2626
</ItemGroup>
2727
</Project>

FileFormat.Cells/Workbook.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ public void Save()
650650
public void Save(string filePath)
651651
{
652652
this.workbookpart.Workbook.Save();
653-
this.spreadsheetDocument.Close();
653+
this.spreadsheetDocument.Dispose();
654654

655655
File.WriteAllBytes(filePath, this.ms.ToArray()); // Write the MemoryStream back to the file
656656
}
@@ -663,7 +663,7 @@ public void Save(Stream stream)
663663

664664
var clonedDocument = this.spreadsheetDocument.Clone(stream);
665665
workbookpart.Workbook.Save();
666-
spreadsheetDocument.Close();
666+
spreadsheetDocument.Dispose();
667667
stream.Close();
668668

669669
}

FileFormat.Cells/Worksheet.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,18 +827,23 @@ private ValidationRule CreateValidationRuleFromDataValidation(DataValidation dat
827827

828828
private ValidationType DetermineValidationType(DataValidationValues openXmlType)
829829
{
830+
var values = Enum.GetNames(typeof(DataValidationValues));
831+
Console.WriteLine("Available DataValidationValues:");
832+
foreach (var value in values)
833+
{
834+
Console.WriteLine(value);
835+
}
830836
// Map the OpenXML DataValidationValues to your ValidationType enum
831837
// This mapping depends on how closely your ValidationType enum aligns with OpenXML's types
832838
// Example mapping:
833-
switch (openXmlType)
839+
switch (openXmlType.ToString()) // If DataValidationValues is now a string enum
834840
{
835-
case DataValidationValues.List:
841+
case "List":
836842
return ValidationType.List;
837-
case DataValidationValues.Custom:
843+
case "Custom":
838844
return ValidationType.CustomFormula;
839-
// Map other types...
840845
default:
841-
throw new NotImplementedException("Validation type not supported.");
846+
throw new NotImplementedException($"Validation type '{openXmlType}' not supported.");
842847
}
843848
}
844849

FileFormat.Cells_Tests/FileFormat.Cells_Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
1717
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
1818
<PackageReference Include="coverlet.collector" Version="3.2.0" />
19-
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
19+
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Aspose Pty Ltd
3+
Copyright (c) 2025 Aspose Pty Ltd
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)