Skip to content

Commit d112cfb

Browse files
committed
This related for qax-os/excelize#2340, support set and get show value as of pivot table data fields
- Add new exported PivotTableShowValuesAs data type - Add new exported PivotTableShowValuesAsType enumeration - Add new field ShowValuesAs in the PivotTableField data type - Upgrade GitHub Action packages version
1 parent 23c5b96 commit d112cfb

3 files changed

Lines changed: 87 additions & 4 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
cache: false
2323

2424
- name: Checkout code
25-
uses: actions/checkout@v6
25+
uses: actions/checkout@v7
2626

2727
- name: Checkout excelize-py
28-
uses: actions/checkout@v6
28+
uses: actions/checkout@v7
2929
with:
3030
repository: xuri/excelize-py
3131
path: excelize-py
@@ -104,7 +104,7 @@ jobs:
104104
cache: false
105105

106106
- name: Checkout excelize-py
107-
uses: actions/checkout@v6
107+
uses: actions/checkout@v7
108108
with:
109109
repository: xuri/excelize-py
110110
path: .
@@ -208,7 +208,7 @@ jobs:
208208
if: github.event_name == 'release' && github.event.action == 'published'
209209
steps:
210210
- name: Checkout code
211-
uses: actions/checkout@v6
211+
uses: actions/checkout@v7
212212

213213
- name: Setup dotnet
214214
uses: actions/setup-dotnet@v5

Excelize/TypesC.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,14 @@ public unsafe struct Chart
544544
public int* Overlap;
545545
}
546546

547+
[StructLayout(LayoutKind.Sequential)]
548+
public unsafe struct PivotTableShowValuesAs
549+
{
550+
public byte Type;
551+
public sbyte* BaseField;
552+
public sbyte* BaseItem;
553+
}
554+
547555
[StructLayout(LayoutKind.Sequential)]
548556
public unsafe struct PivotTableField
549557
{
@@ -567,6 +575,7 @@ public unsafe struct PivotTableField
567575
public int NumFmt;
568576
public int SelectedItemsLen;
569577
public sbyte** SelectedItems;
578+
public PivotTableShowValuesAs ShowValuesAs;
570579
}
571580

572581
[StructLayout(LayoutKind.Sequential)]

Excelize/TypesCs.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ public enum PictureInsertType : byte
223223
PictureInsertTypeDISPIMG = 3,
224224
}
225225

226+
/// <summary>
227+
/// PivotTableShowValuesAsType defines the calculation type enumeration.
228+
/// </summary>
229+
public enum PivotTableShowValuesAsType : byte
230+
{
231+
PivotTableShowValuesAsNoCalculation = 0,
232+
PivotTableShowValuesAsPercentOfGrandTotal = 1,
233+
PivotTableShowValuesAsPercentOfColumnTotal = 2,
234+
PivotTableShowValuesAsPercentOfRowTotal = 3,
235+
PivotTableShowValuesAsPercentOf = 4,
236+
PivotTableShowValuesAsPercentOfParentRowTotal = 5,
237+
PivotTableShowValuesAsPercentOfParentColumnTotal = 6,
238+
PivotTableShowValuesAsPercentOfParentTotal = 7,
239+
PivotTableShowValuesAsDifferenceFrom = 8,
240+
PivotTableShowValuesAsPercentDifferenceFrom = 9,
241+
PivotTableShowValuesAsRunningTotalIn = 10,
242+
PivotTableShowValuesAsPercentRunningTotalIn = 11,
243+
PivotTableShowValuesAsRankSmallestToLargest = 12,
244+
PivotTableShowValuesAsRankLargestToSmallest = 13,
245+
PivotTableShowValuesAsIndex = 14,
246+
}
247+
226248
/// <summary>
227249
/// Interface is a struct that can be used to represent any of the supported
228250
/// value types in the library, including int, string, double, bool,
@@ -769,6 +791,7 @@ public struct PivotTableField
769791
public bool DefaultSubtotal;
770792
public int NumFmt;
771793
public string[]? SelectedItems;
794+
public PivotTableShowValuesAs ShowValuesAs;
772795
}
773796

774797
/// <summary>
@@ -875,6 +898,17 @@ public struct SheetProtectionOptions
875898
public bool Sort;
876899
}
877900

901+
/// <summary>
902+
/// PivotTableShowValuesAs directly maps the show value as settings of the
903+
/// pivot table.
904+
/// </summary>
905+
public struct PivotTableShowValuesAs
906+
{
907+
public PivotTableShowValuesAsType Type;
908+
public string BaseField;
909+
public string BaseItem;
910+
}
911+
878912
/// <summary>
879913
/// Represents the settings of the slicer.
880914
/// </summary>
@@ -911,6 +945,46 @@ public struct SheetProtectionOptions
911945
/// <c>AddPivotTable</c> function, the same field must also have its
912946
/// selected item range specified at the time the pivot table is created.
913947
/// </para>
948+
/// <para><b>ShowValuesAs</b> specifies the calculation type for showing
949+
/// values in a pivot table values fields. The possible values for the
950+
/// <c>Type</c> field of <c>ShowValuesAs</c> are:
951+
/// <list type="bullet">
952+
/// <item><description><c>PivotTableShowValuesAsNoCalculation</c></description></item>
953+
/// <item><description><c>PivotTableShowValuesAsPercentOfGrandTotal</c></description></item>
954+
/// <item><description><c>PivotTableShowValuesAsPercentOfColumnTotal</c></description></item>
955+
/// <item><description><c>PivotTableShowValuesAsPercentOfRowTotal</c></description></item>
956+
/// <item><description><c>PivotTableShowValuesAsPercentOf</c></description></item>
957+
/// <item><description><c>PivotTableShowValuesAsPercentOfParentRowTotal</c></description></item>
958+
/// <item><description><c>PivotTableShowValuesAsPercentOfParentColumnTotal</c></description></item>
959+
/// <item><description><c>PivotTableShowValuesAsPercentOfParentTotal</c></description></item>
960+
/// <item><description><c>PivotTableShowValuesAsDifferenceFrom</c></description></item>
961+
/// <item><description><c>PivotTableShowValuesAsPercentDifferenceFrom</c></description></item>
962+
/// <item><description><c>PivotTableShowValuesAsRunningTotalIn</c></description></item>
963+
/// <item><description><c>PivotTableShowValuesAsPercentRunningTotalIn</c></description></item>
964+
/// <item><description><c>PivotTableShowValuesAsRankSmallestToLargest</c></description></item>
965+
/// <item><description><c>PivotTableShowValuesAsRankLargestToSmallest</c></description></item>
966+
/// <item><description><c>PivotTableShowValuesAsIndex</c></description></item>
967+
/// </list>
968+
/// Note that the base field and base item settings of <c>ShowValuesAs</c>
969+
/// are only required for some calculation types, the calculation types
970+
/// requires base field settings are:
971+
/// <list type="bullet">
972+
/// <item><description><c>PivotTableShowValuesAsPercentOf</c></description></item>
973+
/// <item><description><c>PivotTableShowValuesAsPercentOfParentTotal</c></description></item>
974+
/// <item><description><c>PivotTableShowValuesAsDifferenceFrom</c></description></item>
975+
/// <item><description><c>PivotTableShowValuesAsPercentDifferenceFrom</c></description></item>
976+
/// <item><description><c>PivotTableShowValuesAsRunningTotalIn</c></description></item>
977+
/// <item><description><c>PivotTableShowValuesAsPercentRunningTotalIn</c></description></item>
978+
/// <item><description><c>PivotTableShowValuesAsRankSmallestToLargest</c></description></item>
979+
/// <item><description><c>PivotTableShowValuesAsRankLargestToSmallest</c></description></item>
980+
/// </list>
981+
/// The supported calculation types requires base item settings are:
982+
/// <list type="bullet">
983+
/// <item><description><c>PivotTableShowValuesAsPercentOf</c></description></item>
984+
/// <item><description><c>PivotTableShowValuesAsDifferenceFrom</c></description></item>
985+
/// <item><description><c>PivotTableShowValuesAsPercentDifferenceFrom</c></description></item>
986+
/// </list>
987+
/// </para>
914988
/// </remarks>
915989
public struct SlicerOptions
916990
{

0 commit comments

Comments
 (0)