Skip to content

Commit 5b6f76e

Browse files
Update v2.3.2 (bug fix)
1 parent 9f8b307 commit 5b6f76e

File tree

553 files changed

+1923
-1916
lines changed

Some content is hidden

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

553 files changed

+1923
-1916
lines changed

Changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## v2.3.2
4+
---
5+
Release Date: **30.05.2018**
6+
7+
- Fixed a bug in the processing of column widths. Bug fix provided by Johan Lindvall
8+
9+
310
## v2.3.1
411
---
512
Release Date: **12.03.2018**

Demo/Program.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void Main(string[] args)
3737
/* ### PERFORMANCE TESTS ### */
3838
// # Use tests in this section to test the performance of PicoXLSX
3939
/* ######################### */
40-
// Testing.Performance.StressTest("stressTest.xlsx", "worksheet", 15000, 100);
40+
// Testing.Performance.StressTest("stressTest.xlsx", "worksheet", 15000, 100);
4141
/* ######################### */
4242
}
4343

@@ -144,14 +144,14 @@ private static void Demo3()
144144
workbook.CurrentWorksheet.AddNextCell(4); // Add cell A4
145145
int row = workbook.CurrentWorksheet.GetCurrentRowNumber(); // Get the row number (will be 4 = row 5)
146146
int col = workbook.CurrentWorksheet.GetCurrentColumnNumber(); // Get the column number (will be 0 = column A)
147-
workbook.CurrentWorksheet.AddNextCell("This cell has the row number " + (row+1) + " and column number " + (col+1));
147+
workbook.CurrentWorksheet.AddNextCell("This cell has the row number " + (row + 1) + " and column number " + (col + 1));
148148
workbook.CurrentWorksheet.GoToNextColumn(); // Go to Column B
149149
workbook.CurrentWorksheet.AddNextCell("A"); // Add cell B1
150150
workbook.CurrentWorksheet.AddNextCell("B"); // Add cell B2
151151
workbook.CurrentWorksheet.AddNextCell("C"); // Add cell B3
152152
workbook.CurrentWorksheet.AddNextCell("D"); // Add cell B4
153153
workbook.CurrentWorksheet.RemoveCell("A2"); // Delete cell A2
154-
workbook.CurrentWorksheet.RemoveCell(1,1); // Delete cell B2
154+
workbook.CurrentWorksheet.RemoveCell(1, 1); // Delete cell B2
155155
workbook.CurrentWorksheet.GoToNextRow(3); // Move 3 rows down
156156
object value = workbook.CurrentWorksheet.GetCell(1, 2).Value; // Gets the value of cell B3
157157
workbook.CurrentWorksheet.AddNextCell("Value of B3 is: " + value);
@@ -165,7 +165,7 @@ private static void Demo4()
165165
{
166166
Workbook workbook = new Workbook("test4.xlsx", "Sheet1"); // Create new workbook
167167
List<object> values = new List<object>() { "Header1", "Header2", "Header3" }; // Create a List of values
168-
workbook.CurrentWorksheet.AddCellRange(values, new Cell.Address(0,0), new Cell.Address(2,0)); // Add a cell range to A4 - C4
168+
workbook.CurrentWorksheet.AddCellRange(values, new Cell.Address(0, 0), new Cell.Address(2, 0)); // Add a cell range to A4 - C4
169169
workbook.CurrentWorksheet.Cells["A1"].SetStyle(Style.BasicStyles.Bold); // Assign predefined basic style to cell
170170
workbook.CurrentWorksheet.Cells["B1"].SetStyle(Style.BasicStyles.Bold); // Assign predefined basic style to cell
171171
workbook.CurrentWorksheet.Cells["C1"].SetStyle(Style.BasicStyles.Bold); // Assign predefined basic style to cell
@@ -204,7 +204,7 @@ private static void Demo4()
204204
workbook.CurrentWorksheet.SetColumnWidth(2, 25f); // Set column width
205205
workbook.CurrentWorksheet.SetRowHeight(0, 20); // Set row height
206206
workbook.CurrentWorksheet.SetRowHeight(1, 30); // Set row height
207-
207+
208208
workbook.Save(); // Save the workbook
209209
}
210210

@@ -259,7 +259,7 @@ private static void Demo6()
259259
workbook.CurrentWorksheet.AddNextCell("Cell B1"); // Add cell B1
260260
workbook.CurrentWorksheet.Cells["A1"].SetCellLockedState(false, true); // Set the locking state of cell A1 (not locked but value is hidden when cell selected)
261261
workbook.AddWorksheet("PWD-Protected"); // Add a new worksheet
262-
workbook.CurrentWorksheet.AddCell("This worksheet is password protected. The password is:",0,0); // Add cell A1
262+
workbook.CurrentWorksheet.AddCell("This worksheet is password protected. The password is:", 0, 0); // Add cell A1
263263
workbook.CurrentWorksheet.AddCell("test123", 0, 1); // Add cell A2
264264
workbook.CurrentWorksheet.SetSheetProtectionPassword("test123"); // Set the password "test123"
265265
workbook.SetWorkbookProtection(true, true, true, null); // Set workbook protection (windows locked, structure locked, no password)
@@ -287,7 +287,7 @@ private static void Demo7()
287287
ws.SetAutoFilter(1, 3); // Set auto-filter for column B to D
288288
workbook.SaveAs("test7.xlsx"); // Save the workbook
289289
}
290-
290+
291291
/// <summary>
292292
/// This demo shows the usage of cell and worksheet selection, auto-sanitizing of worksheet names
293293
/// </summary>
@@ -298,11 +298,11 @@ private static void Demo8()
298298
workbook.CurrentWorksheet.SetSelectedCells("A5:B10"); // Set the selection to the range A5:B10
299299
workbook.AddWorksheet("Sheet2"); // Create new worksheet
300300
workbook.CurrentWorksheet.AddNextCell("Test2"); // Add cell A1
301-
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
301+
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
302302
workbook.CurrentWorksheet.SetSelectedCells(range); // Set the selection to the range
303303
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)
304304
workbook.CurrentWorksheet.AddNextCell("Test3"); // Add cell A1
305-
workbook.CurrentWorksheet.SetSelectedCells(new Cell.Address(2,2), new Cell.Address(4,4)); // Set the selection to the range C3:E5
305+
workbook.CurrentWorksheet.SetSelectedCells(new Cell.Address(2, 2), new Cell.Address(4, 4)); // Set the selection to the range C3:E5
306306
workbook.SetSelectedWorksheet(1); // Set the second Tab as selected (zero-based: 1)
307307
workbook.Save(); // Save the workbook
308308
}
@@ -313,7 +313,7 @@ private static void Demo8()
313313
private static void Demo9()
314314
{
315315
Workbook workbook = new Workbook("test9.xlsx", "sheet1"); // Create a new workbook
316-
List<object> numbers = new List<object> {1.15d, 2.225d, 13.8d, 15d, 15.1d, 17.22d, 22d, 107.5d, 128d }; // Create a list of numbers
316+
List<object> numbers = new List<object> { 1.15d, 2.225d, 13.8d, 15d, 15.1d, 17.22d, 22d, 107.5d, 128d }; // Create a list of numbers
317317
List<object> texts = new List<object>() { "value 1", "value 2", "value 3", "value 4", "value 5", "value 6", "value 7", "value 8", "value 9" }; // Create a list of strings (for vlookup)
318318
workbook.WS.Value("Numbers", Style.BasicStyles.Bold); // Add a header with a basic style
319319
workbook.WS.Value("Values", Style.BasicStyles.Bold); // Add a header with a basic style
@@ -372,4 +372,4 @@ private static void Demo9()
372372
}
373373

374374
}
375-
}
375+
}

Demo/Testing/Performance.cs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,45 @@ public class Performance
2828
/// <remarks>The data type is determined per column randomly. In case of strings, random ASCII characters from 1 to 256 characters are written into the cells</remarks>
2929
public static void StressTest(string filename, string sheetname, int rows, int cols)
3030
{
31-
System.Console.WriteLine("Starting performance test - Generating Array...");
32-
List<List<object>> field = new List<List<object>>();
33-
List<object> row;
34-
List<int> colTypes = new List<int>();
35-
DateTime min = new DateTime(1901, 01, 01);
36-
DateTime max = new DateTime(2100, 01, 01);
37-
int j;
38-
for(int i = 0; i < cols; i++)
39-
{
40-
colTypes.Add(Utils.PseudoRandomInteger(1, 6));
41-
}
42-
for (int i = 0; i < rows; i++)
43-
{
44-
row = new List<object>();
45-
for(j = 0; j < cols; j++)
46-
{
47-
if (colTypes[j] == 1) {row.Add(Utils.PseduoRandomDate(min, max));}
48-
else if (colTypes[j] == 2) {row.Add(Utils.PseudoRandomBool());}
49-
else if (colTypes[j] == 3) {row.Add(Utils.PseudoRandomDouble(double.MinValue, double.MaxValue));}
50-
else if (colTypes[j] == 4) {row.Add(Utils.PseudoRandomInteger(int.MinValue, int.MaxValue));}
51-
else if (colTypes[j] == 5) {row.Add(Utils.PseudoRandomLong(long.MinValue, long.MaxValue));}
52-
else if (colTypes[j] == 6) {row.Add(Utils.PseudoRandomString(1,256));}
53-
}
54-
field.Add(row);
55-
}
56-
System.Console.WriteLine("Writing cells...");
57-
PicoXLSX.Workbook b = new PicoXLSX.Workbook(filename, sheetname);
58-
PicoXLSX.Worksheet s = b.CurrentWorksheet;
59-
s.CurrentCellDirection = PicoXLSX.Worksheet.CellDirection.ColumnToColumn;
60-
for (int i = 0; i < rows; i++)
61-
{
62-
for(j = 0; j < cols; j++)
63-
{
64-
s.AddNextCell(field[i][j]);
65-
}
66-
s.GoToNextRow();
67-
}
68-
System.Console.WriteLine("Saving workbook...");
69-
b.Save();
31+
System.Console.WriteLine("Starting performance test - Generating Array...");
32+
List<List<object>> field = new List<List<object>>();
33+
List<object> row;
34+
List<int> colTypes = new List<int>();
35+
DateTime min = new DateTime(1901, 01, 01);
36+
DateTime max = new DateTime(2100, 01, 01);
37+
int j;
38+
for (int i = 0; i < cols; i++)
39+
{
40+
colTypes.Add(Utils.PseudoRandomInteger(1, 6));
41+
}
42+
for (int i = 0; i < rows; i++)
43+
{
44+
row = new List<object>();
45+
for (j = 0; j < cols; j++)
46+
{
47+
if (colTypes[j] == 1) { row.Add(Utils.PseduoRandomDate(min, max)); }
48+
else if (colTypes[j] == 2) { row.Add(Utils.PseudoRandomBool()); }
49+
else if (colTypes[j] == 3) { row.Add(Utils.PseudoRandomDouble(double.MinValue, double.MaxValue)); }
50+
else if (colTypes[j] == 4) { row.Add(Utils.PseudoRandomInteger(int.MinValue, int.MaxValue)); }
51+
else if (colTypes[j] == 5) { row.Add(Utils.PseudoRandomLong(long.MinValue, long.MaxValue)); }
52+
else if (colTypes[j] == 6) { row.Add(Utils.PseudoRandomString(1, 256)); }
53+
}
54+
field.Add(row);
55+
}
56+
System.Console.WriteLine("Writing cells...");
57+
PicoXLSX.Workbook b = new PicoXLSX.Workbook(filename, sheetname);
58+
PicoXLSX.Worksheet s = b.CurrentWorksheet;
59+
s.CurrentCellDirection = PicoXLSX.Worksheet.CellDirection.ColumnToColumn;
60+
for (int i = 0; i < rows; i++)
61+
{
62+
for (j = 0; j < cols; j++)
63+
{
64+
s.AddNextCell(field[i][j]);
65+
}
66+
s.GoToNextRow();
67+
}
68+
System.Console.WriteLine("Saving workbook...");
69+
b.Save();
7070
System.Console.WriteLine("Workbook saved");
7171
}
7272

Demo/Testing/Utils.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,32 @@ public static string PseudoRandomString(int length)
3535
}
3636
return sb.ToString();
3737
}
38-
38+
3939
/// <summary>
4040
/// Gets a (pseudo) random string of ASCII characters within a minimum and maximum range
4141
/// </summary>
4242
/// <param name="minLength">Minimum length</param>
4343
/// <param name="maxLength">Maximum length</param>
4444
/// <returns>Randomly generated string</returns>
45-
public static string PseudoRandomString(int minLength, int maxLength)
46-
{
47-
int len = PseudoRandomInteger(minLength, maxLength);
48-
return PseudoRandomString(len);
49-
}
50-
45+
public static string PseudoRandomString(int minLength, int maxLength)
46+
{
47+
int len = PseudoRandomInteger(minLength, maxLength);
48+
return PseudoRandomString(len);
49+
}
50+
5151
/// <summary>
52-
/// Gets a (pseudo) random long within a minimum and maximum value
52+
/// Gets a (pseudo) random long within a minimum and maximum value
5353
/// </summary>
54-
/// <param name="minLength">Minimum value</param>
55-
/// <param name="maxLength">Maximum value</param>
56-
/// <returns>Randomly generated long</returns>
54+
/// <param name="minLength">Minimum value</param>
55+
/// <param name="maxLength">Maximum value</param>
56+
/// <returns>Randomly generated long</returns>
5757
public static long PseudoRandomLong(long min, long max)
5858
{
59-
if (rnd == null) { rnd = new Random(DateTime.Now.Millisecond); }
60-
byte[] buffer = new byte[8];
61-
rnd.NextBytes(buffer);
62-
long longRnd = BitConverter.ToInt64(buffer, 0);
63-
return (Math.Abs(longRnd % (max - min)) + min);
59+
if (rnd == null) { rnd = new Random(DateTime.Now.Millisecond); }
60+
byte[] buffer = new byte[8];
61+
rnd.NextBytes(buffer);
62+
long longRnd = BitConverter.ToInt64(buffer, 0);
63+
return (Math.Abs(longRnd % (max - min)) + min);
6464
}
6565

6666
/// <summary>
@@ -84,18 +84,18 @@ public static int PseudoRandomInteger(int min, int max)
8484
public static double PseudoRandomDouble(double min, double max)
8585
{
8686
if (rnd == null) { rnd = new Random(DateTime.Now.Millisecond); }
87-
return (Utils.rnd.NextDouble() * (max - min)) + min ;
87+
return (Utils.rnd.NextDouble() * (max - min)) + min;
8888
}
89-
89+
9090
/// <summary>
9191
/// Gets a (pseudo) random bool
9292
/// </summary>
9393
/// <returns>Randomly generated bool</returns>
9494
public static bool PseudoRandomBool()
9595
{
96-
int i = Utils.PseudoRandomInteger(0,1);
97-
if (i == 0){ return false;}
98-
else {return true; }
96+
int i = Utils.PseudoRandomInteger(0, 1);
97+
if (i == 0) { return false; }
98+
else { return true; }
9999
}
100100

101101
/// <summary>
@@ -106,9 +106,9 @@ public static bool PseudoRandomBool()
106106
/// <returns>Randomly generated DateTime</returns>
107107
/// <remarks>Excel, respectively its OADate function does not support a dates before 30th December 1899. Such dates will cause an exception in PicoXLSX</remarks>
108108
public static DateTime PseduoRandomDate(DateTime min, DateTime max)
109-
{
110-
long ticks = PseudoRandomLong(min.Ticks, max.Ticks);
111-
return new DateTime(ticks);
109+
{
110+
long ticks = PseudoRandomLong(min.Ticks, max.Ticks);
111+
return new DateTime(ticks);
112112
}
113113

114114

0 commit comments

Comments
 (0)