Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into FixBug926
Browse files Browse the repository at this point in the history
  • Loading branch information
Bykiev committed Mar 12, 2024
2 parents 9f69b61 + 5a189bb commit ae31cf0
Show file tree
Hide file tree
Showing 56 changed files with 4,348 additions and 389 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
- main
- master
- 'release*'
- 'poi/*'

jobs:
windows-latest:
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<DebugType>portable</DebugType>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>

<VersionPrefix>2.6.1</VersionPrefix>
<VersionPrefix>2.7.0</VersionPrefix>
<Title>NPOI</Title>
<Authors>Tony Qu,NPOI Contributors</Authors>
<Owners>Nissl Lab</Owners>
Expand Down
4 changes: 2 additions & 2 deletions OpenXmlFormats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.6.1.0")]
[assembly: AssemblyFileVersion("2.6.1.0")]
[assembly: AssemblyVersion("2.7.0.0")]
[assembly: AssemblyFileVersion("2.7.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0.0")]
#if NETSTANDARD2_1 || NET6_0_OR_GREATER || NETSTANDARD2_0 || NET40
[assembly: AllowPartiallyTrustedCallers]
Expand Down
14 changes: 11 additions & 3 deletions OpenXmlFormats/Wordprocessing/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,21 @@ public CT_SectPr sectPr
this.sectPrField = value;
}
}
public CT_Tbl AddNewTbl()
public CT_Tbl AddNewTbl(int? pos = null)
{
CT_Tbl tbl = new CT_Tbl();
lock (this)
{
this.itemsField.Add(tbl);
this.itemsElementNameField.Add(DocumentBodyItemChoiceType.tbl);
if(pos.HasValue)
{
this.itemsField.Insert(pos.Value, tbl);
this.itemsElementNameField.Insert(pos.Value, DocumentBodyItemChoiceType.tbl);
}
else
{
this.itemsField.Add(tbl);
this.itemsElementNameField.Add(DocumentBodyItemChoiceType.tbl);
}
}
return tbl;
}
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ This project is the .NET version of Apache POI project. With NPOI, you can read/

About Donation 关于捐款
============
Since Github sponsorship is not supported in China so far, it's hard to get donation from Github channel. I'm strictly limiting my contribution time on NPOI these 2 years although it looks to be still maintained well.
If you profits/benefits from NPOI and you believe it's useful, please [sponsor me via Github Sponsor](https://github.com/sponsors/tonyqus) or [donate this project](https://github.com/nissl-lab/npoi/discussions/923). Thank you!

If you profits/benefits from NPOI and you believe it's useful, please [donate this project](https://github.com/nissl-lab/npoi/discussions/923). Thank you!

如果您从NPOI受益或实现盈利,请[给该项目捐款](https://github.com/nissl-lab/npoi/discussions/923),谢谢!
如果您从NPOI受益或实现盈利,请通过[Github Sponsor赞助我](https://github.com/sponsors/tonyqus)[给该项目捐款](https://github.com/nissl-lab/npoi/discussions/923),谢谢!


Telegram User Group
Expand Down Expand Up @@ -54,7 +52,7 @@ e. Support not only export but also import

f. Real successful cases all over the world

g. [huge amount of basic examples](https://github.com/nissl-lab/npoi-examples)
g. [huge amount of code examples for you to learn how to use NPOI](https://github.com/nissl-lab/npoi-examples)

h. Works on both Windows and Linux

Expand Down
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ $DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "STS"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0
$env:DOTNET_NOLOGO = 1

###########################################################################
# EXECUTION
Expand Down Expand Up @@ -61,6 +60,7 @@ else {
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
$env:PATH = "$DotNetDirectory;$env:PATH"
}

Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
DOTNET_CHANNEL="STS"

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_MULTILEVEL_LOOKUP=0
export DOTNET_NOLOGO=1

###########################################################################
# EXECUTION
Expand Down Expand Up @@ -54,11 +53,12 @@ else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
export PATH="$DOTNET_DIRECTORY:$PATH"
fi

echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"

if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "NUKE_ENTERPRISE_TOKEN" != "" ]]; then
if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then
"$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true
"$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true
fi
Expand Down
8 changes: 2 additions & 6 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ partial class Build : NukeBuild
[Solution] Solution Solution;
[GitRepository] readonly GitRepository GitRepository;

static AbsolutePath SourceDirectory => RootDirectory / "src";

static AbsolutePath ArtifactsDirectory => RootDirectory / "publish";

string TagVersion => GitRepository.Tags.SingleOrDefault(x => x.StartsWith("v"))?[1..];
Expand All @@ -45,8 +43,6 @@ partial class Build : NukeBuild

string VersionSuffix;

static bool IsRunningOnWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

[Secret]
[Parameter("GitHub API token")]
readonly string GitHubToken;
Expand Down Expand Up @@ -101,11 +97,11 @@ static void DeleteCompilationArtifacts()
.Executes(() =>
{
DotNetBuild(_ =>_
.EnableNoRestore()
.SetNoRestore(SucceededTargets.Contains(Restore))
.SetConfiguration(Configuration)
.SetDeterministic(IsServerBuild)
.SetContinuousIntegrationBuild(IsServerBuild)
.SetVerbosity(DotNetVerbosity.Minimal)
.SetVerbosity(DotNetVerbosity.minimal)
// obsolete missing XML documentation comment, XML comment on not valid language element, XML comment has badly formed XML, no matching tag in XML comment
// need to use escaped separator in order for this to work
.AddProperty("NoWarn", string.Join("%3B", new [] { 169, 612, 618, 1591, 1587, 1570, 1572, 1573, 1574 }))
Expand Down
4 changes: 2 additions & 2 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.2" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
</ItemGroup>

</Project>
114 changes: 49 additions & 65 deletions main/HSSF/UserModel/HSSFDataFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,36 @@ the License. You may obtain a copy of the License at
limitations Under the License.
==================================================================== */


namespace NPOI.HSSF.UserModel
{
using System;
using System.Collections;

using NPOI.HSSF.Model;
using NPOI.HSSF.Record;
using System.Collections.Generic;
using NPOI.SS.UserModel;

/*
* Identifies both built-in and user defined formats within a workbook.<p/>
* See {@link BuiltinFormats} for a list of supported built-in formats.<p/>
*
* <b>International Formats</b><br/>
* Since version 2003 Excel has supported international formats. These are denoted
* with a prefix "[$-xxx]" (where xxx is a 1-7 digit hexadecimal number).
* See the Microsoft article
* <a href="http://office.microsoft.com/assistance/hfws.aspx?AssetID=HA010346351033&CTT=6&Origin=EC010272491033">
* Creating international number formats
* </a> for more details on these codes.
*
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Shawn M. Laubach (slaubach at apache dot org)
*/
/// <summary>
/// <para>
/// Identifies both built-in and user defined formats within a workbook.
/// </para>
/// <para>
/// See <see cref="BuiltinFormats"/> for a list of supported built-in formats.
/// </para>
/// <para>
/// <b>International Formats</b><br/>
/// Since version 2003 Excel has supported international formats. These are denoted
/// with a prefix "[$-xxx]" (where xxx is a 1-7 digit hexadecimal number).
/// See the Microsoft article
/// <a href="http://office.microsoft.com/assistance/hfws.aspx?AssetID=HA010346351033&amp;CTT=6&amp;Origin=EC010272491033">
/// Creating international number formats
/// </a> for more details on these codes.
/// </para>
/// </summary>
[Serializable]
public class HSSFDataFormat : IDataFormat
{
/**
* The first user-defined format starts at 164.
*/
//The first user-defined format starts at 164.
public const int FIRST_USER_DEFINED_FORMAT_INDEX = 164;

private static List<string> builtinFormats = new List<string>(BuiltinFormats.GetAll());
Expand All @@ -67,18 +65,17 @@ public HSSFDataFormat(InternalWorkbook workbook)
{
this.workbook = workbook;
IEnumerator i = workbook.Formats.GetEnumerator();
while (i.MoveNext())
while(i.MoveNext())
{
FormatRecord r = (FormatRecord)i.Current;
for (int j = formats.Count; formats.Count <= r.IndexCode; j++)
for(int j = formats.Count; formats.Count <= r.IndexCode; j++)
{
formats.Add(null);
}
formats[r.IndexCode] = r.FormatString;
}
}


public static List<string> GetBuiltinFormats()
{
return builtinFormats;
Expand All @@ -90,24 +87,9 @@ public static List<string> GetBuiltinFormats()
/// </summary>
/// <param name="format">The format string matching a built in format.</param>
/// <returns>index of format or -1 if Undefined.</returns>
public static short GetBuiltinFormat(String format)
public static short GetBuiltinFormat(string format)
{
if (format.ToUpper().Equals("TEXT"))
format = "@";

short retval = -1;

for (short k = 0; k <= 0x31; k++)
{
String nformat = (String)builtinFormats[k];

if ((nformat != null) && nformat.Equals(format))
{
retval = k;
break;
}
}
return retval;
return (short) BuiltinFormats.GetBuiltinFormat(format);
}

/// <summary>
Expand All @@ -117,12 +99,12 @@ public static short GetBuiltinFormat(String format)
/// </summary>
/// <param name="pFormat">The format string matching a built in format.</param>
/// <returns>index of format.</returns>
public short GetFormat(String pFormat)
public short GetFormat(string pFormat)
{
IEnumerator i;
int ind;
String format;
if (pFormat.ToUpper().Equals("TEXT"))
string format;
if(pFormat.Equals("TEXT", StringComparison.OrdinalIgnoreCase))
{
format = "@";
}
Expand All @@ -131,13 +113,13 @@ public short GetFormat(String pFormat)
format = pFormat;
}

if (!movedBuiltins)
if(!movedBuiltins)
{
i = builtinFormats.GetEnumerator();
ind = 0;
while (i.MoveNext())
while(i.MoveNext())
{
for (int j = formats.Count; formats.Count < ind + 1; j++)
for(int j = formats.Count; formats.Count < ind + 1; j++)
{
formats.Add(null);
}
Expand All @@ -148,44 +130,44 @@ public short GetFormat(String pFormat)
}
i = formats.GetEnumerator();
ind = 0;
while (i.MoveNext())
while(i.MoveNext())
{
if (format.Equals(i.Current))
return (short)ind;
if(format.Equals(i.Current))
return (short) ind;

ind++;
}

ind = workbook.GetFormat(format, true);
for (int j = formats.Count; formats.Count < ind + 1; j++)
for(int j = formats.Count; formats.Count < ind + 1; j++)
{
formats.Add(null);
}
formats[ind] = format;

return (short)ind;
return (short) ind;
}

/// <summary>
/// Get the format string that matches the given format index
/// </summary>
/// <param name="index">The index of a format.</param>
/// <returns>string represented at index of format or null if there Is not a format at that index</returns>
public String GetFormat(short index)
public string GetFormat(short index)
{
if (movedBuiltins)
return (String)formats[index];
if(movedBuiltins)
return formats[index];

if (index == -1)
if(index == -1)
return null;

String fmt = formats.Count > index ? formats[index] : null;
string fmt = formats.Count > index ? formats[index] : null;

if (builtinFormats.Count > index
if(builtinFormats.Count > index
&& builtinFormats[index] != null)
{
// It's in the built in range
if (fmt != null)
if(fmt != null)
{
// It's been overriden, use that value
return fmt;
Expand All @@ -204,9 +186,9 @@ public String GetFormat(short index)
/// </summary>
/// <param name="index">The index of a built in format.</param>
/// <returns>string represented at index of format or null if there Is not a builtin format at that index</returns>
public static String GetBuiltinFormat(short index)
public static string GetBuiltinFormat(short index)
{
return (String)builtinFormats[index];
return builtinFormats[index];
}

/// <summary>
Expand All @@ -220,13 +202,15 @@ public static int NumberOfBuiltinBuiltinFormats
return builtinFormats.Count;
}
}
/**
* Ensures that the formats list can hold entries
* up to and including the entry with this index
*/

/// <summary>
/// Ensures that the formats list can hold entries
/// up to and including the entry with this index
/// </summary>
/// <param name="index"></param>
private void EnsureFormatsSize(int index)
{
if (formats.Count <= index)
if(formats.Count <= index)
{
formats.Capacity = (index + 1);
}
Expand Down
Loading

0 comments on commit ae31cf0

Please sign in to comment.