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

DocumentBuilder: ISource #17

Merged
merged 24 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"isRoot": true,
"tools": {
"paket": {
"version": "5.249.0",
"version": "5.257.0",
"commands": [
"paket"
]
},
"fake-cli": {
"version": "5.20.2",
"version": "5.20.3",
"commands": [
"fake"
]
},
"dotnet-serve": {
"version": "1.7.132",
"version": "1.8.15",
"commands": [
"dotnet-serve"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
dotnet: [3.1.302]
dotnet: [5.0.102]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ _ReSharper.Caches/
.paket/
AssemblyInfo.Generated.cs
TestFiles/PublishSlides/output/

.ionide
8 changes: 0 additions & 8 deletions Clippit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlConverter01", "OpenXmlP
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ListItemRetriever01", "OpenXmlPowerToolsExamples\ListItemRetriever01\ListItemRetriever01.csproj", "{04935FA6-E48B-496F-8D6A-41A59232303D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MarkupSimplifierApp", "OpenXmlPowerToolsExamples\MarkupSimplifierApp\MarkupSimplifierApp.csproj", "{0CCE83BA-8B8B-4B98-8846-B62A61FDF170}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetricsGetter01", "OpenXmlPowerToolsExamples\MetricsGetter01\MetricsGetter01.csproj", "{ED37372C-DFBF-4720-BD4B-CE1415961038}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenXmlRegex01", "OpenXmlPowerToolsExamples\OpenXmlRegex01\OpenXmlRegex01.csproj", "{4330D46F-6703-4BA2-844D-177F722C0820}"
Expand Down Expand Up @@ -79,7 +77,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
LICENSE.txt = LICENSE.txt
paket.dependencies = paket.dependencies
README.md = README.md
docs\RELEASE_NOTES.md = docs\RELEASE_NOTES.md
Expand Down Expand Up @@ -135,10 +132,6 @@ Global
{04935FA6-E48B-496F-8D6A-41A59232303D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04935FA6-E48B-496F-8D6A-41A59232303D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04935FA6-E48B-496F-8D6A-41A59232303D}.Release|Any CPU.Build.0 = Release|Any CPU
{0CCE83BA-8B8B-4B98-8846-B62A61FDF170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0CCE83BA-8B8B-4B98-8846-B62A61FDF170}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0CCE83BA-8B8B-4B98-8846-B62A61FDF170}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0CCE83BA-8B8B-4B98-8846-B62A61FDF170}.Release|Any CPU.Build.0 = Release|Any CPU
{ED37372C-DFBF-4720-BD4B-CE1415961038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED37372C-DFBF-4720-BD4B-CE1415961038}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED37372C-DFBF-4720-BD4B-CE1415961038}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -246,7 +239,6 @@ Global
{618B95DB-3A70-4DC8-BD87-00F636F72453} = {A83D6B58-6D38-46AF-8C20-5CFC170A1063}
{BC9E7408-508D-482D-8602-96E76ACBB5EA} = {A83D6B58-6D38-46AF-8C20-5CFC170A1063}
{04935FA6-E48B-496F-8D6A-41A59232303D} = {A83D6B58-6D38-46AF-8C20-5CFC170A1063}
{0CCE83BA-8B8B-4B98-8846-B62A61FDF170} = {A83D6B58-6D38-46AF-8C20-5CFC170A1063}
{ED37372C-DFBF-4720-BD4B-CE1415961038} = {A83D6B58-6D38-46AF-8C20-5CFC170A1063}
{4330D46F-6703-4BA2-844D-177F722C0820} = {A83D6B58-6D38-46AF-8C20-5CFC170A1063}
{6785A554-BBBB-480C-8E4D-9FE90DD91A46} = {A83D6B58-6D38-46AF-8C20-5CFC170A1063}
Expand Down
3 changes: 3 additions & 0 deletions OpenXmlPowerTools.Tests/HtmlToWmlConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ public void HW001(string name)
var annotatedHtmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceHtmlFi.Name.Replace(".html", "-4-Annotated.txt")));

if (!sourceCopiedToDestHtmlFi.Exists)
{
Directory.CreateDirectory(sourceCopiedToDestHtmlFi.DirectoryName);
File.Copy(sourceHtmlFi.FullName, sourceCopiedToDestHtmlFi.FullName);
}
XElement html = HtmlToWmlReadAsXElement.ReadAsXElement(sourceCopiedToDestHtmlFi);

string htmlString = html.ToString();
Expand Down
4 changes: 2 additions & 2 deletions OpenXmlPowerTools.Tests/OpenXmlPowerTools.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net5.0</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RootNamespace>Clippit.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void PublishUsingPublishSlides(string sourcePath)

using var srcStream = File.Open(sourcePath, FileMode.Open);
var openSettings = new OpenSettings {AutoSave = false};
using var srcDoc = OpenXmlExtensions.OpenPresentation(srcStream, true, openSettings);
using var srcDoc = OpenXmlExtensions.OpenPresentation(srcStream, false, openSettings);

var title = srcDoc.PackageProperties.Title ?? string.Empty;
var modified = srcDoc.PackageProperties.Modified;
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void CF002(string name, string sheetName, string range, string expected,

var dataTemplateFileNameSuffix = string.Format("-2-Generated-XmlData-{0}.xml", range.Replace(":", ""));
var dataXmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", dataTemplateFileNameSuffix)));
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true))
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, false))
{
var rangeXml = SmlDataRetriever.RetrieveRange(sDoc, sheetName, range);
string displayValue = (string)rangeXml.Descendants("DisplayValue").FirstOrDefault();
Expand Down
10 changes: 5 additions & 5 deletions OpenXmlPowerTools.Tests/SmlToHtmlConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void SH005_ConvertSheet(string name, string sheetName)

var dataTemplateFileNameSuffix = "-2-Generated-XmlData-Entire-Sheet.xml";
var dataXmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", dataTemplateFileNameSuffix)));
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true))
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, false))
{
var settings = new SmlToHtmlConverterSettings();
var rangeXml = SmlDataRetriever.RetrieveSheet(sDoc, sheetName);
Expand Down Expand Up @@ -125,7 +125,7 @@ public void SH004_ConvertRange(string name, string sheetName, string range)

var dataTemplateFileNameSuffix = string.Format("-2-Generated-XmlData-{0}.xml", range.Replace(":", ""));
var dataXmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", dataTemplateFileNameSuffix)));
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true))
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, false))
{
var settings = new SmlToHtmlConverterSettings();
var rangeXml = SmlDataRetriever.RetrieveRange(sDoc, sheetName, range);
Expand Down Expand Up @@ -155,7 +155,7 @@ public void SH003_ConvertTable(string name, string tableName)
File.Copy(sourceXlsx.FullName, sourceCopiedToDestXlsx.FullName);

var dataXmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", "-2-Generated-XmlData.xml")));
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true))
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, false))
{
var settings = new SmlToHtmlConverterSettings();
var rangeXml = SmlDataRetriever.RetrieveTable(sDoc, tableName);
Expand All @@ -169,7 +169,7 @@ public void SH002_SheetNames(string name, int numberOfSheets)
{
DirectoryInfo sourceDir = new DirectoryInfo("../../../../TestFiles/");
FileInfo sourceXlsx = new FileInfo(Path.Combine(sourceDir.FullName, name));
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true))
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, false))
{
var sheetNames = SmlDataRetriever.SheetNames(sDoc);
Assert.Equal(numberOfSheets, sheetNames.Length);
Expand All @@ -183,7 +183,7 @@ public void SH001_TableNames(string name, int numberOfTables)
{
DirectoryInfo sourceDir = new DirectoryInfo("../../../../TestFiles/");
FileInfo sourceXlsx = new FileInfo(Path.Combine(sourceDir.FullName, name));
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true))
using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, false))
{
var table = SmlDataRetriever.TableNames(sDoc);
Assert.Equal(numberOfTables, table.Length);
Expand Down
18 changes: 18 additions & 0 deletions OpenXmlPowerTools.Tests/SpreadsheetWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,24 @@ public void SW002_AllDataTypes()
},
}
},
new Sw.RowDfn
{
Cells = new Sw.CellDfn[]
{
new Sw.CellDfn {
CellDataType = Sw.CellDataType.Date,
Value = new DateTimeOffset(new DateTime(2012, 1, 8), TimeSpan.Zero),
FormatCode = "mm-dd-yy",
},
new Sw.CellDfn {
CellDataType = Sw.CellDataType.Date,
Value = new DateTimeOffset(new DateTime(2012, 1, 9), TimeSpan.Zero),
FormatCode = "mm-dd-yy",
Bold = true,
HorizontalCellAlignment = Sw.HorizontalCellAlignment.Center,
},
}
},
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Validation;
using Clippit;
using Clippit.Word;

using Xunit;

#if !ELIDE_XUNIT_TESTS
Expand Down