Skip to content

Commit 2004c1f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into FixSixLaborsFont
2 parents 58d67eb + b91b047 commit 2004c1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+528
-199
lines changed

.github/workflows/CI.yml

-14
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ jobs:
2929
timeout-minutes: 20
3030
steps:
3131
- uses: actions/checkout@v3
32-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
33-
uses: actions/cache@v3
34-
with:
35-
path: |
36-
.nuke/temp
37-
~/.nuget/packages
38-
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
3932
- name: 'Run: Clean, Test, Pack'
4033
run: ./build.cmd Clean Test Pack
4134
- name: 'Publish: artifacts'
@@ -49,13 +42,6 @@ jobs:
4942
timeout-minutes: 20
5043
steps:
5144
- uses: actions/checkout@v3
52-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
53-
uses: actions/cache@v3
54-
with:
55-
path: |
56-
.nuke/temp
57-
~/.nuget/packages
58-
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
5945
- name: 'Run: Clean, Test, Pack'
6046
run: ./build.cmd Clean Test Pack
6147
- name: 'Publish: artifacts'

.github/workflows/PR.yml

-14
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ jobs:
2525
timeout-minutes: 20
2626
steps:
2727
- uses: actions/checkout@v3
28-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
29-
uses: actions/cache@v3
30-
with:
31-
path: |
32-
.nuke/temp
33-
~/.nuget/packages
34-
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
3528
- name: 'Run: Clean, Test, Pack'
3629
run: ./build.cmd Clean Test Pack
3730
- name: 'Publish: artifacts'
@@ -45,13 +38,6 @@ jobs:
4538
timeout-minutes: 20
4639
steps:
4740
- uses: actions/checkout@v3
48-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
49-
uses: actions/cache@v3
50-
with:
51-
path: |
52-
.nuke/temp
53-
~/.nuget/packages
54-
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
5541
- name: 'Run: Clean, Test, Pack'
5642
run: ./build.cmd Clean Test Pack
5743
- name: 'Publish: artifacts'

OpenXmlFormats/Shared/Math.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,7 @@ internal void Write(StreamWriter sw, string nodeName)
407407
{
408408
sw.Write(string.Format("<m:{0}", nodeName));
409409
XmlHelper.WriteAttribute(sw, "m:val", this.val);
410-
sw.Write(">");
411-
sw.Write(string.Format("</m:{0}>", nodeName));
410+
sw.Write("/>");
412411
}
413412

414413
[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
@@ -448,8 +447,7 @@ internal void Write(StreamWriter sw, string nodeName)
448447
{
449448
sw.Write(string.Format("<m:{0}", nodeName));
450449
XmlHelper.WriteAttribute(sw, "m:val", this.val.ToString());
451-
sw.Write(">");
452-
sw.Write(string.Format("</m:{0}>", nodeName));
450+
sw.Write("/>");
453451
}
454452

455453
private ST_LimLoc valField;

OpenXmlFormats/Spreadsheet/Styles/CT_CellProtection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static CT_CellProtection Parse(XmlNode node, XmlNamespaceManager namespac
3030
if (node == null)
3131
return null;
3232
CT_CellProtection ctObj = new CT_CellProtection();
33-
ctObj.locked = XmlHelper.ReadBool(node.Attributes["locked"]);
33+
ctObj.locked = XmlHelper.ReadBool(node.Attributes["locked"], true);
3434
ctObj.hidden = XmlHelper.ReadBool(node.Attributes["hidden"]);
3535
return ctObj;
3636
}

OpenXmlFormats/Wordprocessing/HdrFtr.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,17 @@ internal void Write(StreamWriter sw, string nodeName)
191191
sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
192192
sw.Write(string.Format("<w:{0} ", nodeName));
193193
sw.Write("xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ");
194+
sw.Write("xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ");
195+
sw.Write("xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ");
194196
//sw.Write("xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ");
195-
sw.Write("xmlns:o=\"urn:schemas-microsoft-com:office:office\" ");
197+
sw.Write("xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:oel=\"http://schemas.microsoft.com/office/2019/extlst\" ");
196198
sw.Write("xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ");
197199
sw.Write("xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ");
198200
sw.Write("xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ");
199201
sw.Write("xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ");
200-
sw.Write("xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\"");
201-
sw.Write(">");
202+
sw.Write("xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" xmlns:w16du=\"http://schemas.microsoft.com/office/word/2023/wordml/word16du\" xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" ");
203+
sw.Write("xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ");
204+
sw.Write("mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\">");
202205
foreach (object o in this.Items)
203206
{
204207
if (o is CT_TrackChange)
@@ -1045,7 +1048,7 @@ internal void Write(StreamWriter sw, string nodeName)
10451048
{
10461049
sw.Write(string.Format("<w:{0}", nodeName));
10471050
XmlHelper.WriteAttribute(sw, "w:type", this.type.ToString());
1048-
XmlHelper.WriteAttribute(sw, "w:id", this.id);
1051+
XmlHelper.WriteAttribute(sw, "w:id", this.id, true);
10491052
sw.Write(">");
10501053
int i = 0;
10511054
foreach (object o in this.Items)

OpenXmlFormats/Wordprocessing/Numbering.cs

+20-3
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,6 @@ public static CT_AbstractNum Parse(XmlNode node, XmlNamespaceManager namespaceMa
11361136
return ctObj;
11371137
}
11381138

1139-
1140-
11411139
internal void Write(StreamWriter sw, string nodeName)
11421140
{
11431141
sw.Write(string.Format("<w:{0}", nodeName));
@@ -1165,7 +1163,14 @@ internal void Write(StreamWriter sw, string nodeName)
11651163
sw.WriteEndW(nodeName);
11661164
}
11671165

1168-
1166+
public CT_Lvl AddNewLvl()
1167+
{
1168+
if (this.lvl == null)
1169+
this.lvlField = new List<CT_Lvl>();
1170+
CT_Lvl lvl = new CT_Lvl();
1171+
this.lvlField.Add(lvl);
1172+
return lvl;
1173+
}
11691174

11701175

11711176
public int SizeOfLvlArray()
@@ -1582,6 +1587,18 @@ public bool tentativeSpecified
15821587
this.tentativeFieldSpecified = value;
15831588
}
15841589
}
1590+
1591+
public CT_NumFmt AddNewNumFmt()
1592+
{
1593+
this.numFmtField = new CT_NumFmt();
1594+
return this.numFmtField;
1595+
}
1596+
1597+
public CT_LevelText AddNewLvlText()
1598+
{
1599+
this.lvlText = new CT_LevelText();
1600+
return this.lvlText;
1601+
}
15851602
}
15861603

15871604

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ What's NPOI
1111
/>
1212
</a>
1313
<br />
14-
This project is the .NET version of POI Java project. With NPOI, you can read/write Office 2003/2007 files very easily.<br />
14+
This project is the .NET version of Apache POI project. With NPOI, you can read/write Office 2003/2007 files very easily.<br />
1515

1616
About Donation 关于捐款
1717
============

build/Build.GitHubAction.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1+
using System;
12
using Nuke.Common.CI.GitHubActions;
23

34
[GitHubActions("CI",
45
GitHubActionsImage.WindowsLatest,
56
GitHubActionsImage.UbuntuLatest,
67
OnPushBranches = new[] { "main", "master" },
78
InvokedTargets = new[] { nameof(Clean), nameof(Test), nameof(Pack) },
8-
TimeoutMinutes = 20
9+
TimeoutMinutes = 20,
10+
CacheKeyFiles = new string[0]
911
)]
1012
[GitHubActions("PR",
1113
GitHubActionsImage.WindowsLatest,
1214
GitHubActionsImage.UbuntuLatest,
1315
On = new [] { GitHubActionsTrigger.PullRequest },
1416
InvokedTargets = new[] { nameof(Clean), nameof(Test), nameof(Pack) },
15-
TimeoutMinutes = 20
17+
TimeoutMinutes = 20,
18+
CacheKeyFiles = new string[0]
1619
)]
1720
partial class Build
1821
{

build/Build.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ static void DeleteCompilationArtifacts()
103103
.OnlyWhenDynamic(() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Host is GitHubActions)
104104
.Executes(() =>
105105
{
106-
ProcessTasks.StartProcess("sudo", "apt install -y fonts-noto-color-emoji");
107-
ProcessTasks.StartProcess("mkdir", "-p /usr/local/share/fonts");
108-
ProcessTasks.StartProcess("cp", "/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf /usr/local/share/fonts/");
109-
ProcessTasks.StartProcess("chmod", "644 /usr/local/share/fonts/NotoColorEmoji.ttf");
110-
ProcessTasks.StartProcess("fc-cache", "-fv");
106+
static void StartSudoProcess(string arguments) => ProcessTasks.StartProcess("sudo", arguments).WaitForExit();
107+
108+
// replace broken font - the one coming from APT doesn't contain all expected tables
109+
StartSudoProcess("rm /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf");
110+
StartSudoProcess("curl -sS -L -o /usr/share/fonts/truetype/noto/NotoColorEmoji-Regular.ttf https://fonts.gstatic.com/s/notocoloremoji/v25/Yq6P-KqIXTD0t4D9z1ESnKM3-HpFab5s79iz64w.ttf");
111111
});
112112

113113
Target Pack => _ => _

main/HSSF/UserModel/HSSFCell.cs

+29-20
Original file line numberDiff line numberDiff line change
@@ -850,44 +850,53 @@ private void CheckFormulaCachedValueType(CellType expectedTypeCode, FormulaRecor
850850

851851
/// <summary>
852852
/// Get the value of the cell as a date. For strings we throw an exception.
853-
/// For blank cells we return a null.
853+
/// For non-Numeric cells including blank cell we return a null.
854854
/// </summary>
855855
/// <value>The date cell value.</value>
856-
public DateTime DateCellValue
856+
public DateTime? DateCellValue
857857
{
858858
get
859859
{
860-
if (cellType == CellType.Blank)
860+
if (CellType != CellType.Numeric && CellType != CellType.Formula)
861861
{
862-
return DateTime.MaxValue;
862+
return null;
863863
}
864-
if (cellType == CellType.String)
865-
{
866-
throw new InvalidDataException(
867-
"You cannot get a date value from a String based cell");
868-
}
869-
if (cellType == CellType.Boolean)
870-
{
871-
throw new InvalidDataException(
872-
"You cannot get a date value from a bool cell");
873-
}
874-
if (cellType == CellType.Error)
864+
double value = this.NumericCellValue;
865+
return DateUtil.GetJavaDate(value, book.IsDate1904());
866+
}
867+
}
868+
#if NET6_0_OR_GREATER
869+
public DateOnly? DateOnlyCellValue
870+
{
871+
get{
872+
if (CellType != CellType.Numeric && CellType != CellType.Formula)
875873
{
876-
throw new InvalidDataException(
877-
"You cannot get a date value from an error cell");
874+
return null;
878875
}
879876
double value = this.NumericCellValue;
880877
if (book.IsDate1904())
881878
{
882-
return DateUtil.GetJavaDate(value, true);
879+
return DateOnly.FromDateTime(DateUtil.GetJavaDate(value, true));
883880
}
884881
else
885882
{
886-
return DateUtil.GetJavaDate(value, false);
883+
return DateOnly.FromDateTime(DateUtil.GetJavaDate(value, false));
884+
}
885+
}
886+
}
887+
public TimeOnly? TimeOnlyCellValue
888+
{
889+
get{
890+
if (CellType != CellType.Numeric && CellType != CellType.Formula)
891+
{
892+
return null;
887893
}
894+
double value = NumericCellValue;
895+
bool date1904 = Sheet.Workbook.IsDate1904();
896+
return TimeOnly.FromDateTime(DateUtil.GetJavaDate(value, date1904));
888897
}
889898
}
890-
899+
#endif
891900
/// <summary>
892901
/// Get the value of the cell as a string - for numeric cells we throw an exception.
893902
/// For blank cells we return an empty string.

0 commit comments

Comments
 (0)