NanoXLSX.Writer 3.0.0-rc.3
Loading...
Searching...
No Matches
PackagePartDefinition.cs
1/*
2 * NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3 * Copyright Raphael Stoeckli © 2025
4 * This library is licensed under the MIT License.
5 * You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6 */
7
8using System.Collections.Generic;
9using System.Linq;
10
12{
17 internal class PackagePartDefinition
18 {
19
20 #region staticFields
24 internal const int WORKBOOK_PACKAGE_PART_INDEX = 0;
28 internal const int METADATA_PACKAGE_PART_START_INDEX = 1000;
32 internal const int WORKSHEET_PACKAGE_PART_START_INDEX = 10000;
36 internal const int POST_WORSHEET_PACKAGE_PART_START_INDEX = 2000000;
37 #endregion
38
39 #region enums
43 internal enum PackagePartType
44 {
48 Root,
52 Worksheet,
56 Other,
57 }
58 #endregion
59
63 public DocumentPath Path { get; private set; }
67 public PackagePartType PartType { get; private set; }
71 public int OrderNumber { get; private set; }
75 public string ContentType { get; private set; }
79 public string RelationshipType { get; private set; }
80
90 public PackagePartDefinition(PackagePartType type, int orderNumber, string fileNameInPackage, string pathInPackage, string contentType, string relationshipType)
91 : this(type, orderNumber, new DocumentPath(fileNameInPackage, pathInPackage), contentType, relationshipType)
92 { }
93
102 internal PackagePartDefinition(PackagePartType type, int orderNumber, DocumentPath documentPath, string contentType, string relationshipType)
103 {
104 this.PartType = type;
105 this.OrderNumber = orderNumber;
106 this.Path = documentPath;
107 this.ContentType = contentType;
108 this.RelationshipType = relationshipType;
109 }
110
116 internal int GetWorksheetIndex()
117 {
118 return this.OrderNumber - WORKSHEET_PACKAGE_PART_START_INDEX;
119 }
120
126 internal static List<PackagePartDefinition> Sort(List<PackagePartDefinition> packagePartDefinitions)
127 {
128 return packagePartDefinitions.OrderBy(p => p.OrderNumber).ToList();
129 }
130 }
131
132}