Skip to content

Commit 0ffbce7

Browse files
Amendments to Release v3.1.0
1 parent d20dca4 commit 0ffbce7

File tree

831 files changed

+1248
-1194
lines changed

Some content is hidden

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

831 files changed

+1248
-1194
lines changed

Changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
## v3.1.0
44

55
---
6-
Release Date: **03.11.2022**
6+
Release Date: **11.11.2022**
77

88
- Added a several methods in the Worksheet class to add multiple ranges of selected cells
9+
- Removed internal escaping of custom number format codes for now
910
- Updated example in demo
1011

12+
Note: The incomplete internal escaping of custom number format codes was removed due to the potential high complexity.
13+
Escaping must be performed currently by hand, according to OOXML specs: Part 1 - Fundamentals And Markup Language Reference, Chapter 18.8.31
14+
1115
## v3.0.2
1216

1317
---

Demo .NET Standard/Demo .NET Standard.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Copyright>Copyright Raphael Stoeckli © 2022</Copyright>
99
<RepositoryUrl>https://github.com/rabanti-github/PicoXLSX.git</RepositoryUrl>
1010
<PackageProjectUrl>https://github.com/rabanti-github/PicoXLSX</PackageProjectUrl>
11-
<AssemblyVersion>3.1.2.0</AssemblyVersion>
11+
<AssemblyVersion>3.1.0.0</AssemblyVersion>
1212
<FileVersion>3.1.0.0</FileVersion>
1313
<Version>3.1.0</Version>
1414
<Description>Demo Library showing the use of PicoXLSX, a library to generate Microsoft Excel files (XLSX) in an easy and native way</Description>

Demo/Program.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private static void Demo2()
162162
{
163163
Workbook workbook = new Workbook(false); // Create new workbook
164164
workbook.AddWorksheet("Sheet1"); // Add a new Worksheet and set it as current sheet
165-
workbook.CurrentWorksheet.AddNextCell("月曜日"); // Add cell A1 (Unicode)
165+
workbook.CurrentWorksheet.AddNextCell("月曜日"); // Add cell A1 (Unicode)
166166
workbook.CurrentWorksheet.AddNextCell(-987); // Add cell B1
167167
workbook.CurrentWorksheet.AddNextCell(false); // Add cell C1
168168
workbook.CurrentWorksheet.GoToNextRow(); // Go to Row 2
@@ -351,19 +351,20 @@ private static void Demo7()
351351
/// </summary>
352352
private static void Demo8()
353353
{
354-
Workbook workbook = new Workbook("test8.xlsx", "Sheet*1", true); // Create new workbook with invalid sheet name (*); Auto-Sanitizing will replace * with _
355-
workbook.CurrentWorksheet.AddNextCell("Test"); // Add cell A1
354+
Workbook workbook = new Workbook("test8.xlsx", "Sheet*1", true); // Create new workbook with invalid sheet name (*); Auto-Sanitizing will replace * with _
355+
workbook.CurrentWorksheet.AddNextCell("Test"); // Add cell A1
356356
workbook.CurrentWorksheet.AddSelectedCells("A5:B10"); // Set the selection to the range A5:B10
357357
workbook.CurrentWorksheet.AddSelectedCells("D2:D2"); // Add another cell as selected on this worksheet
358-
workbook.AddWorksheet("Sheet2"); // Create new worksheet
359-
workbook.CurrentWorksheet.AddNextCell("Test2"); // Add cell A1
360-
Cell.Range range = new Cell.Range(new Cell.Address(1, 1), new Cell.Address(3, 3)); // Create a cell range for the selection B2:D4
358+
workbook.AddWorksheet("Sheet2"); // Create new worksheet
359+
workbook.CurrentWorksheet.AddNextCell("Test2"); // Add cell A1
360+
Cell.Range range = new Cell.Range(new Cell.Address(1, 1), new Cell.Address(3, 3)); // Create a cell range for the selection B2:D4
361361
workbook.CurrentWorksheet.SetSelectedCells(range); // Set the selection to the range (deprecated method to clear all previous definitions)
362-
workbook.AddWorksheet("Sheet2", true); // Create new worksheet with already existing name; The name will be changed to Sheet21 due to auto-sanitizing (appending of 1)
363-
workbook.CurrentWorksheet.AddNextCell("Test3"); // Add cell A1
362+
workbook.AddWorksheet("Sheet2", true); // Create new worksheet with already existing name; The name will be changed to Sheet21 due to auto-sanitizing (appending of 1)
363+
workbook.CurrentWorksheet.AddNextCell("Test3"); // Add cell A1
364364
workbook.CurrentWorksheet.AddSelectedCells(new Cell.Address(2, 2), new Cell.Address(4, 4)); // Set the selection to the range C3:E5
365-
workbook.CurrentWorksheet.AddSelectedCells(new Cell.Address(5, 1), new Cell.Address(5, 1)); // Set the selection to F2 as range workbook.SetSelectedWorksheet(1); // Set the second Tab as selected (zero-based: 1)
366-
workbook.Save(); // Save the workbook
365+
workbook.CurrentWorksheet.AddSelectedCells(new Cell.Address(5, 1), new Cell.Address(5, 1)); // Set the selection to F2 as range
366+
workbook.SetSelectedWorksheet(1); // Set the second Tab as selected (zero-based: 1)
367+
workbook.Save(); // Save the workbook
367368
}
368369

369370
/// <summary>

PicoXLSX/LowLevel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,8 +1321,9 @@ private string CreateStyleNumberFormatString()
13211321
{
13221322
throw new FormatException("The number format style component with the ID " + item.CustomFormatID.ToString("G", culture) + " cannot be null or empty");
13231323
}
1324-
String customFormat = Style.NumberFormat.EscapeFormatCode(item.CustomFormatCode);
1325-
sb.Append("<numFmt formatCode=\"").Append(EscapeXmlAttributeChars(customFormat)).Append("\" numFmtId=\"").Append(item.CustomFormatID.ToString("G", culture)).Append("\"/>");
1324+
// OOXML: Escaping according to Chp.18.8.31
1325+
// TODO: v4> Add a custom format builder as plugin
1326+
sb.Append("<numFmt formatCode=\"").Append(EscapeXmlAttributeChars(item.CustomFormatCode)).Append("\" numFmtId=\"").Append(item.CustomFormatID.ToString("G", culture)).Append("\"/>");
13261327
}
13271328
}
13281329
return sb.ToString();

PicoXLSX/Style.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,8 +1637,10 @@ public enum FormatRange
16371637
private string customFormatCode;
16381638

16391639
/// <summary>
1640-
/// Gets or sets the custom format code in the notation of Excel
1640+
/// Gets or sets the raw custom format code in the notation of Excel. <b>The code is not escaped automatically</b>
16411641
/// </summary>
1642+
/// <remarks>Currently, there is no auto-escaping applied to custom format strings. For instance, to add a white space, internally it is escaped by a backspace (\ ).
1643+
/// To get a valid custom format code, this escaping must be applied manually, according to OOXML specs: Part 1 - Fundamentals And Markup Language Reference, Chapter 18.8.31</remarks>
16421644
[Append]
16431645
public string CustomFormatCode
16441646
{
@@ -1774,17 +1776,6 @@ public static FormatRange TryParseFormatNumber(int number, out FormatNumber form
17741776
}
17751777
}
17761778

1777-
/// <summary>
1778-
/// Method to escape Backslashes in custom format codes
1779-
/// </summary>
1780-
/// <param name="rawFormatCode">Raw value to escape.</param>
1781-
/// <returns>.</returns>
1782-
internal static string EscapeFormatCode(string rawFormatCode)
1783-
{
1784-
// TODO: Add further rules, if discovered
1785-
return rawFormatCode.Replace("\\", "\\\\");
1786-
}
1787-
17881779
/// <summary>
17891780
/// Override toString method
17901781
/// </summary>

PicoXLSX/Workbook.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public Workbook(string filename, string sheetName, bool sanitizeSheetName)
236236
}
237237

238238
/// <summary>
239-
/// Adds a color value (HEX; 6-digit RGB or 8-digit RGBA) to the MRU list
239+
/// Adds a color value (HEX; 6-digit RGB or 8-digit ARGB) to the MRU list
240240
/// </summary>
241241
/// <param name="color">RGB code in hex format (either 6 characters, e.g. FF00AC or 8 characters with leading alpha value). Alpha will be set to full opacity (FF) in case of 6 characters.</param>
242242
public void AddMruColor(string color)

docs/Documentation.chm

4.38 KB
Binary file not shown.

docs/WebKI.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<HelpKINode Title="fields" Url="html/6b4c9529-b9f0-eef5-c9eb-d6f1264c1098.htm" />
5151
<HelpKINode Title="methods" Url="html/9cc3d927-4fe1-4258-f686-7eaa017d02da.htm" />
5252
</HelpKINode>
53+
<HelpKINode Title="AddSelectedCells method" Url="html/74c5f441-dc74-63f7-b801-05789442675b.htm" />
5354
<HelpKINode Title="AddStyle method">
5455
<HelpKINode Title="StyleManager.AddStyle Method " Url="html/7e87b332-f94d-566e-db81-79c888998270.htm" />
5556
<HelpKINode Title="StyleRepository.AddStyle Method " Url="html/9cafd5f7-06fd-22a6-29ae-65a093f8690f.htm" />
@@ -387,7 +388,6 @@
387388
<HelpKINode Title="Address.Equals Method " Url="html/33743d81-b315-d8e9-0ee8-71a4b97d03f5.htm" />
388389
<HelpKINode Title="Cell.Range.Equals Method " Url="html/44f619c9-c65c-2a60-f98f-7031ba901265.htm" />
389390
</HelpKINode>
390-
<HelpKINode Title="EscapeFormatCode method" Url="html/d02d6463-3c0d-6afa-488b-cd30ea5aa1ee.htm" />
391391
<HelpKINode Title="EscapeXmlAttributeChars method" Url="html/04d55bc3-2b54-2465-608a-d705ead294d1.htm" />
392392
<HelpKINode Title="EscapeXmlChars method" Url="html/11c53472-18fa-2c19-2559-4da54f647cb4.htm" />
393393
<HelpKINode Title="Family property" Url="html/cfacdb92-0bd0-b0e1-171e-5c6c14ca980b.htm" />
@@ -623,8 +623,8 @@
623623
<HelpKINode Title="LockWindowsIfProtected property" Url="html/ef8f758a-e442-70b6-604f-51cbdcf200f6.htm" />
624624
<HelpKINode Title="LowLevel class">
625625
<HelpKINode Title="LowLevel Class" Url="html/21d4a25a-f2b5-5ec4-8b84-8fcee13605a0.htm" />
626-
<HelpKINode Title="constructor" Url="html/20d28a8a-5f98-83cc-261b-e6510f44cdc1.htm" />
627626
<HelpKINode Title="constructor" Url="html/dbbcf6a6-b50e-1d72-6dc4-dfa09f1aca4e.htm" />
627+
<HelpKINode Title="constructor" Url="html/20d28a8a-5f98-83cc-261b-e6510f44cdc1.htm" />
628628
<HelpKINode Title="fields" Url="html/1defef87-f57c-99ce-4f31-432379bba20f.htm" />
629629
<HelpKINode Title="methods" Url="html/322b3913-e838-3a82-7cd5-10444749e661.htm" />
630630
</HelpKINode>
@@ -686,8 +686,8 @@
686686
<HelpKINode Title="LowLevel.INVARIANT_CULTURE field" Url="html/01e5f765-39d1-fba1-30d8-545857665b78.htm" />
687687
<HelpKINode Title="LowLevel.LAST_ALLOWED_EXCEL_DATE field" Url="html/d73ed8bc-b6fa-5f25-f693-4f1178a18f5b.htm" />
688688
<HelpKINode Title="LowLevel.LowLevel constructor">
689-
<HelpKINode Title="LowLevel Constructor " Url="html/dbbcf6a6-b50e-1d72-6dc4-dfa09f1aca4e.htm" />
690689
<HelpKINode Title="LowLevel Constructor " Url="html/20d28a8a-5f98-83cc-261b-e6510f44cdc1.htm" />
690+
<HelpKINode Title="LowLevel Constructor " Url="html/dbbcf6a6-b50e-1d72-6dc4-dfa09f1aca4e.htm" />
691691
</HelpKINode>
692692
<HelpKINode Title="LowLevel.MAX_OADATE_VALUE field" Url="html/a01ef06a-899e-2b5c-eb1d-8af6774b5b5b.htm" />
693693
<HelpKINode Title="LowLevel.MIN_OADATE_VALUE field" Url="html/40c47d62-7e79-1505-a510-f8d48099ee21.htm" />
@@ -927,6 +927,7 @@
927927
<HelpKINode Title="fields" Url="html/8885f0f5-27c0-ceff-b65f-f20588c1183b.htm" />
928928
<HelpKINode Title="methods" Url="html/44f2e3cd-9651-5a1c-1fac-c62278710fd1.htm" />
929929
</HelpKINode>
930+
<HelpKINode Title="SelectedCellRanges property" Url="html/657a4c4a-d008-32e2-175c-b5389ba8efb3.htm" />
930931
<HelpKINode Title="SelectedCells property" Url="html/52f77cc1-0e55-7d17-7fea-05cd10309df3.htm" />
931932
<HelpKINode Title="SelectedWorksheet property" Url="html/78059228-0c26-29c6-222e-5b932f7d6448.htm" />
932933
<HelpKINode Title="selectLockedCells field" Url="html/73e200ae-93f9-a655-9d47-fe2aca4a104b.htm" />
@@ -1076,8 +1077,8 @@
10761077
<HelpKINode Title="Style.Border.ToString method" Url="html/48b82667-2f26-6ab0-b07d-9678447d30e9.htm" />
10771078
<HelpKINode Title="Style.CellXf class">
10781079
<HelpKINode Title="Style.CellXf Class" Url="html/1cea405c-b47e-ee50-0614-4894cbd9ab25.htm" />
1079-
<HelpKINode Title="constructor" Url="html/4c26c15f-a878-15fb-9399-291d227b1375.htm" />
10801080
<HelpKINode Title="constructor" Url="html/aed057e2-ea89-fc4d-9fe5-ed850c36bec2.htm" />
1081+
<HelpKINode Title="constructor" Url="html/4c26c15f-a878-15fb-9399-291d227b1375.htm" />
10811082
</HelpKINode>
10821083
<HelpKINode Title="Style.CellXf.Alignment property" Url="html/be0671ae-d0b7-f60f-219d-4da15ed60b11.htm" />
10831084
<HelpKINode Title="Style.CellXf.CalculateInternalRotation method" Url="html/c533f83c-5d21-6f4b-6cb2-56c362a0c86d.htm" />
@@ -1174,8 +1175,8 @@
11741175
<HelpKINode Title="Style.Fill.ValidateColor method" Url="html/b9df0c56-b02d-8fd2-6c50-1fa89141cd15.htm" />
11751176
<HelpKINode Title="Style.Font class">
11761177
<HelpKINode Title="Style.Font Class" Url="html/781509fe-fd0c-f65d-ab2d-c825a259bbfa.htm" />
1177-
<HelpKINode Title="constructor" Url="html/dfd57e48-bd6b-02a7-f764-8fb65b569ee2.htm" />
11781178
<HelpKINode Title="constructor" Url="html/676d29d4-4bd6-ed3c-7982-66b9d273d0f5.htm" />
1179+
<HelpKINode Title="constructor" Url="html/dfd57e48-bd6b-02a7-f764-8fb65b569ee2.htm" />
11791180
</HelpKINode>
11801181
<HelpKINode Title="Style.Font.Bold property" Url="html/f80efe30-749f-1110-e464-3da1eb4dd6a2.htm" />
11811182
<HelpKINode Title="Style.Font.Charset property" Url="html/048ce452-128b-2c67-6de7-cc4d26274f16.htm" />
@@ -1190,8 +1191,8 @@
11901191
<HelpKINode Title="Style.Font.DEFAULT_VERTICAL_ALIGN field" Url="html/a2bd5904-6ce3-41ed-cad1-d2cfe84a68ce.htm" />
11911192
<HelpKINode Title="Style.Font.Family property" Url="html/cfacdb92-0bd0-b0e1-171e-5c6c14ca980b.htm" />
11921193
<HelpKINode Title="Style.Font.Font constructor">
1193-
<HelpKINode Title="Style.Font Constructor " Url="html/dfd57e48-bd6b-02a7-f764-8fb65b569ee2.htm" />
11941194
<HelpKINode Title="Style.Font Constructor " Url="html/676d29d4-4bd6-ed3c-7982-66b9d273d0f5.htm" />
1195+
<HelpKINode Title="Style.Font Constructor " Url="html/dfd57e48-bd6b-02a7-f764-8fb65b569ee2.htm" />
11951196
</HelpKINode>
11961197
<HelpKINode Title="Style.Font.GetHashCode method" Url="html/c94f33d1-8bbf-4fec-225e-be56c632eb91.htm" />
11971198
<HelpKINode Title="Style.Font.IsDefaultFont property" Url="html/5e91fe81-5bd6-8aa7-ca94-e8d6c6295045.htm" />
@@ -1235,7 +1236,6 @@
12351236
<HelpKINode Title="Style.NumberFormat.CustomFormatID property" Url="html/b5ce5d3d-618f-aa0c-f565-1908056bd14a.htm" />
12361237
<HelpKINode Title="Style.NumberFormat.CUSTOMFORMAT_START_NUMBER field" Url="html/12faf6c9-9e57-61a7-29ac-e2b8fafaf1d7.htm" />
12371238
<HelpKINode Title="Style.NumberFormat.DEFAULT_NUMBER field" Url="html/240a6fe2-6ed0-6afd-72a4-056dad383686.htm" />
1238-
<HelpKINode Title="Style.NumberFormat.EscapeFormatCode method" Url="html/d02d6463-3c0d-6afa-488b-cd30ea5aa1ee.htm" />
12391239
<HelpKINode Title="Style.NumberFormat.FormatNumber class" Url="html/551f78ab-758c-cbe9-8e7c-1cef0a87f040.htm" />
12401240
<HelpKINode Title="Style.NumberFormat.FormatNumber.custom field" Url="html/6f62914c-4d9d-e351-9a07-1a0e1900cfd3.htm" />
12411241
<HelpKINode Title="Style.NumberFormat.FormatNumber.format_1 field" Url="html/e5193868-f438-9796-f1d0-3a1ab8711e3f.htm" />
@@ -1504,8 +1504,8 @@
15041504
<HelpKINode Title="WorkbookReference property" Url="html/b4d37c83-50bf-5f7d-353a-f0b24fb25a75.htm" />
15051505
<HelpKINode Title="Worksheet class">
15061506
<HelpKINode Title="Worksheet Class" Url="html/c3b3c4d1-7f62-b7df-bb0a-76cecc18fef3.htm" />
1507-
<HelpKINode Title="constructor" Url="html/edb4ea29-ed1f-9c7d-4535-3aa4c2828c19.htm" />
15081507
<HelpKINode Title="constructor" Url="html/648c8cb8-c40d-d174-ccf7-205cf8c9f427.htm" />
1508+
<HelpKINode Title="constructor" Url="html/edb4ea29-ed1f-9c7d-4535-3aa4c2828c19.htm" />
15091509
<HelpKINode Title="fields" Url="html/78cb97f5-810f-f822-4da0-c39b1b23b979.htm" />
15101510
<HelpKINode Title="methods" Url="html/adb3f264-b043-9a46-54d3-4c6ae515d937.htm" />
15111511
<HelpKINode Title="properties" Url="html/f4525299-9cb3-57ae-ddb1-2f5f7ad85754.htm" />
@@ -1522,6 +1522,7 @@
15221522
<HelpKINode Title="Worksheet.AddHiddenRow method" Url="html/77045f88-0564-498f-38c0-408b73d64cf0.htm" />
15231523
<HelpKINode Title="Worksheet.AddNextCell method" Url="html/16026592-80e7-006a-99b6-3f4d1defdd53.htm" />
15241524
<HelpKINode Title="Worksheet.AddNextCellFormula method" Url="html/0e61398a-7c1d-0f11-532d-9640f72744bf.htm" />
1525+
<HelpKINode Title="Worksheet.AddSelectedCells method" Url="html/74c5f441-dc74-63f7-b801-05789442675b.htm" />
15251526
<HelpKINode Title="Worksheet.AutoFilterRange property" Url="html/9d3ffb1d-453a-864c-8be6-916881113798.htm" />
15261527
<HelpKINode Title="Worksheet.CastValue method" Url="html/e61adb5d-f1d8-da1d-73fe-bffd8bde22cc.htm" />
15271528
<HelpKINode Title="Worksheet.CellDirection class" Url="html/357d67a9-19c3-3a83-17db-cc2b8c442940.htm" />
@@ -1605,6 +1606,7 @@
16051606
<HelpKINode Title="Worksheet.ResolveMergedCells method" Url="html/77fc1c53-c951-28fa-6641-52fab6e7729c.htm" />
16061607
<HelpKINode Title="Worksheet.RowHeights property" Url="html/7cbe68af-b70c-331b-76be-40a7e910b532.htm" />
16071608
<HelpKINode Title="Worksheet.SanitizeWorksheetName method" Url="html/6e13912d-c57e-6d1f-3c65-ac9ebdd7a831.htm" />
1609+
<HelpKINode Title="Worksheet.SelectedCellRanges property" Url="html/657a4c4a-d008-32e2-175c-b5389ba8efb3.htm" />
16081610
<HelpKINode Title="Worksheet.SelectedCells property" Url="html/52f77cc1-0e55-7d17-7fea-05cd10309df3.htm" />
16091611
<HelpKINode Title="Worksheet.SetActiveStyle method" Url="html/b94defd3-271e-5206-c564-1043865fe8f8.htm" />
16101612
<HelpKINode Title="Worksheet.SetAutoFilter method" Url="html/b0ecd4c4-3355-86d9-e955-154e78a058cb.htm" />
@@ -1647,8 +1649,8 @@
16471649
<HelpKINode Title="Worksheet.UseSheetProtection property" Url="html/4274e257-3677-f178-81ae-67bf9a9d1d8c.htm" />
16481650
<HelpKINode Title="Worksheet.WorkbookReference property" Url="html/b4d37c83-50bf-5f7d-353a-f0b24fb25a75.htm" />
16491651
<HelpKINode Title="Worksheet.Worksheet constructor">
1650-
<HelpKINode Title="Worksheet Constructor " Url="html/edb4ea29-ed1f-9c7d-4535-3aa4c2828c19.htm" />
16511652
<HelpKINode Title="Worksheet Constructor " Url="html/648c8cb8-c40d-d174-ccf7-205cf8c9f427.htm" />
1653+
<HelpKINode Title="Worksheet Constructor " Url="html/edb4ea29-ed1f-9c7d-4535-3aa4c2828c19.htm" />
16521654
</HelpKINode>
16531655
<HelpKINode Title="Worksheet.WorksheetExists method" Url="html/d2ffb7b8-7790-dab7-a76d-fb7d8dee97d7.htm" />
16541656
<HelpKINode Title="Worksheet.WorksheetPane class" Url="html/6d49ab3c-2dd8-f414-29ca-e25869cac58f.htm" />

0 commit comments

Comments
 (0)