-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathSXSSFSheet.cs
1432 lines (1242 loc) · 42.2 KB
/
SXSSFSheet.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for Additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using NPOI.SS;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.Util;
using NPOI.XSSF.UserModel;
namespace NPOI.XSSF.Streaming
{
public class SXSSFSheet : ISheet
{
// TODO: fields should be private and use public property
internal XSSFSheet _sh;
private SXSSFWorkbook _workbook;
//private TreeMap<Integer, SXSSFRow> _rows = new TreeMap<Integer, SXSSFRow>();
private IDictionary<int, SXSSFRow> _rows = new Dictionary<int, SXSSFRow>();
private SheetDataWriter _writer;
private int _randomAccessWindowSize = SXSSFWorkbook.DEFAULT_WINDOW_SIZE;
private Lazy<AutoSizeColumnTracker> _autoSizeColumnTracker;
private int outlineLevelRow = 0;
private int lastFlushedRowNumber = -1;
private bool allFlushed = false;
private int _FirstRowNum = -1;
private int _LastRowNum = -1;
public SXSSFSheet(SXSSFWorkbook workbook, XSSFSheet xSheet)
{
_workbook = workbook;
_sh = xSheet;
_writer = workbook.CreateSheetDataWriter();
SetRandomAccessWindowSize(_workbook.RandomAccessWindowSize);
_autoSizeColumnTracker = new Lazy<AutoSizeColumnTracker>(
() => new AutoSizeColumnTracker(this));
}
public void SetRandomAccessWindowSize(int value)
{
if (value == 0 || value < -1)
{
throw new ArgumentException("RandomAccessWindowSize must be either -1 or a positive integer");
}
_randomAccessWindowSize = value;
}
public bool Autobreaks
{
get
{
return _sh.Autobreaks;
}
set { _sh.Autobreaks = value; }
}
public int[] ColumnBreaks
{
get
{
return _sh.ColumnBreaks;
}
//set { _sh.ColumnBreaks = value; }
}
public int DefaultColumnWidth
{
get
{
return _sh.DefaultColumnWidth;
}
set
{
_sh.DefaultColumnWidth = value;
}
}
public short DefaultRowHeight
{
get { return _sh.DefaultRowHeight; }
set
{
_sh.DefaultRowHeight = value;
}
}
public float DefaultRowHeightInPoints
{
get
{
return _sh.DefaultRowHeightInPoints;
}
set
{
_sh.DefaultRowHeightInPoints = value;
}
}
public bool DisplayFormulas
{
get
{
return _sh.DisplayFormulas;
}
set { _sh.DisplayFormulas = value; }
}
public bool DisplayGridlines
{
get
{
return _sh.DisplayGridlines;
}
set
{
_sh.DisplayGridlines = value;
}
}
public bool DisplayGuts
{
get { return _sh.DisplayGuts; }
set
{
_sh.DisplayGuts = value;
}
}
public bool DisplayRowColHeadings
{
get
{
return _sh.DisplayRowColHeadings;
}
set
{
_sh.DisplayRowColHeadings = value;
}
}
public bool DisplayZeros
{
get
{
return _sh.DisplayZeros;
}
set
{
_sh.DisplayZeros = value;
}
}
public IDrawing DrawingPatriarch
{
get
{
return _sh.DrawingPatriarch;
}
}
public int FirstRowNum
{
get
{
if (_writer.NumberOfFlushedRows > 0)
return _writer.LowestIndexOfFlushedRows;
return _rows.Count == 0 ? 0 : _FirstRowNum;
}
}
public bool FitToPage
{
get
{
return _sh.FitToPage;
}
set { _sh.FitToPage = value; }
}
public IFooter Footer
{
get
{
return _sh.Footer;
}
}
public bool ForceFormulaRecalculation
{
get
{
return _sh.ForceFormulaRecalculation;
}
set { _sh.ForceFormulaRecalculation = value; }
}
public IHeader Header
{
get { return _sh.Header; }
}
public bool HorizontallyCenter
{
get
{
return _sh.HorizontallyCenter;
}
set { _sh.HorizontallyCenter = value; }
}
public bool IsActive
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public bool IsPrintGridlines
{
get { return _sh.IsPrintGridlines; }
set
{
_sh.IsPrintGridlines = value;
}
}
/**
* Returns whether row and column headings are printed.
*
* @return whether row and column headings are printed
*/
public bool IsPrintRowAndColumnHeadings
{
get
{
return _sh.IsPrintRowAndColumnHeadings;
}
set
{
_sh.IsPrintRowAndColumnHeadings = value;
}
}
public bool IsRightToLeft
{
get
{
return _sh.IsRightToLeft;
}
set
{
_sh.IsRightToLeft = value;
}
}
public bool IsSelected
{
get
{
return _sh.IsSelected;
}
set
{
_sh.IsSelected = value;
}
}
public int LastRowNum
{
get
{
if (_rows.Count == 0)
return _writer.NumberOfFlushedRows > 0 ? LastFlushedRowNumber : 0;
return _LastRowNum;
}
}
public short LeftCol
{
get { return _sh.LeftCol; }
set
{
throw new NotImplementedException();
}
}
public int NumMergedRegions
{
get { return _sh.NumMergedRegions; }
}
/**
* Returns the list of merged regions. If you want multiple regions, this is
* faster than calling {@link #getMergedRegion(int)} each time.
*
* @return the list of merged regions
*/
public List<CellRangeAddress> MergedRegions
{
get { return _sh.MergedRegions; }
}
public PaneInformation PaneInformation
{
get { return _sh.PaneInformation; }
}
public int PhysicalNumberOfRows
{
get
{
return _rows.Count + _writer.NumberOfFlushedRows;
}
}
public IPrintSetup PrintSetup
{
get { return _sh.PrintSetup; }
}
public bool Protect
{
get { return _sh.Protect; }
}
public CellRangeAddress RepeatingColumns
{
get { return _sh.RepeatingColumns; }
set
{
_sh.RepeatingColumns = value;
}
}
public CellRangeAddress RepeatingRows
{
get { return _sh.RepeatingRows; }
set
{
_sh.RepeatingRows = value;
}
}
public int[] RowBreaks
{
get { return _sh.RowBreaks; }
}
public bool RowSumsBelow
{
get { return _sh.RowSumsBelow; }
set
{
_sh.RowSumsBelow = value;
}
}
public bool RowSumsRight
{
get { return _sh.RowSumsRight; }
set
{
_sh.RowSumsRight = value;
}
}
public bool ScenarioProtect
{
get { return _sh.ScenarioProtect; }
}
public ISheetConditionalFormatting SheetConditionalFormatting
{
get { return _sh.SheetConditionalFormatting; }
}
public string SheetName
{
get { return _sh.SheetName; }
}
public short TabColorIndex
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public short TopRow
{
get { return _sh.TopRow; }
set
{
_sh.TopRow = value;
}
}
public bool VerticallyCenter
{
get { return _sh.VerticallyCenter; }
set
{
_sh.VerticallyCenter = value;
}
}
public IWorkbook Workbook
{
get { return _workbook; }
}
public int AddMergedRegion(CellRangeAddress region)
{
return _sh.AddMergedRegion(region);
}
/// <summary>
/// Adds a merged region of cells (hence those cells form one).
/// Skips validation.It is possible to create overlapping merged regions
/// or create a merged region that intersects a multi-cell array formula
/// with this formula, which may result in a corrupt workbook.
/// </summary>
/// <param name="region">region to merge</param>
/// <returns>index of this region</returns>
/// <exception cref="System.ArgumentException">if region contains fewer than 2 cells</exception>
public int AddMergedRegionUnsafe(CellRangeAddress region)
{
return _sh.AddMergedRegionUnsafe(region);
}
/**
* Verify that merged regions do not intersect multi-cell array formulas and
* no merged regions intersect another merged region in this sheet.
*
* @throws InvalidOperationException if region intersects with a multi-cell array formula
* @throws InvalidOperationException if at least one region intersects with another merged region in this sheet
*/
public void ValidateMergedRegions() {
_sh.ValidateMergedRegions();
}
public void AddValidationData(IDataValidation dataValidation)
{
_sh.AddValidationData(dataValidation);
}
/**
* Adjusts the column width to fit the contents.
*
* <p>
* This process can be relatively slow on large sheets, so this should
* normally only be called once per column, at the end of your
* processing.
* </p>
* You can specify whether the content of merged cells should be considered or ignored.
* Default is to ignore merged cells.
*
* <p>
* Special note about SXSSF implementation: You must register the columns you wish to track with
* the SXSSFSheet using {@link #trackColumnForAutoSizing(int)} or {@link #trackAllColumnsForAutoSizing()}.
* This is needed because the rows needed to compute the column width may have fallen outside the
* random access window and been flushed to disk.
* Tracking columns is required even if all rows are in the random access window.
* </p>
* <p><i>New in POI 3.14 beta 1: auto-sizes columns using cells from current and flushed rows.</i></p>
*
* @param column the column index to auto-size
*/
public void AutoSizeColumn(int column)
{
AutoSizeColumn(column, false);
}
/**
* Adjusts the column width to fit the contents.
* <p>
* This process can be relatively slow on large sheets, so this should
* normally only be called once per column, at the end of your
* processing.
* </p>
* You can specify whether the content of merged cells should be considered or ignored.
* Default is to ignore merged cells.
*
* <p>
* Special note about SXSSF implementation: You must register the columns you wish to track with
* the SXSSFSheet using {@link #trackColumnForAutoSizing(int)} or {@link #trackAllColumnsForAutoSizing()}.
* This is needed because the rows needed to compute the column width may have fallen outside the
* random access window and been flushed to disk.
* Tracking columns is required even if all rows are in the random access window.
* </p>
* <p><i>New in POI 3.14 beta 1: auto-sizes columns using cells from current and flushed rows.</i></p>
*
* @param column the column index to auto-size
* @param useMergedCells whether to use the contents of merged cells when calculating the width of the column
*/
public void AutoSizeColumn(int column, bool useMergedCells)
{
// Multiple calls to autoSizeColumn need to look up the best-fit width
// of rows already flushed to disk plus re-calculate the best-fit width
// of rows in the current window. It isn't safe to update the column
// widths before flushing to disk because columns in the random access
// window rows may change in best-fit width. The best-fit width of a cell
// is only fixed when it becomes inaccessible for modification.
// Changes to the shared strings table, styles table, or formulas might
// be able to invalidate the auto-size width without the opportunity
// to recalculate the best-fit width for the flushed rows. This is an
// inherent limitation of SXSSF. If having correct auto-sizing is
// critical, the flushed rows would need to be re-read by the read-only
// XSSF eventmodel (SAX) or the memory-heavy XSSF usermodel (DOM).
int flushedWidth;
try
{
// get the best fit width of rows already flushed to disk
flushedWidth = _autoSizeColumnTracker.Value.GetBestFitColumnWidth(column, useMergedCells);
}
catch (Exception e)
{
throw new InvalidOperationException("Could not auto-size column. Make sure the column was tracked prior to auto-sizing the column.", e);
}
// get the best-fit width of rows currently in the random access window
int activeWidth = (int)(256 * SheetUtil.GetColumnWidth(this, column, useMergedCells));
// the best-fit width for both flushed rows and random access window rows
// flushedWidth or activeWidth may be negative if column contains only blank cells
int bestFitWidth = Math.Max(flushedWidth, activeWidth);
if (bestFitWidth > 0)
{
int maxColumnWidth = 255 * 256; // The maximum column width for an individual cell is 255 characters
int width = Math.Min(bestFitWidth, maxColumnWidth);
SetColumnWidth(column, width);
}
}
public IRow CopyRow(int sourceIndex, int targetIndex)
{
throw new NotImplementedException();
}
public ISheet CopySheet(string Name)
{
throw new NotImplementedException();
}
public ISheet CopySheet(string Name,string newName, bool copyStyle)
{
throw new NotImplementedException();
}
public ISheet CopySheet(string Name, bool copyStyle)
{
throw new NotImplementedException();
}
/// <summary>
/// Get a Hyperlink in this sheet anchored at row, column
/// </summary>
/// <param name="row">The index of the row of the hyperlink, zero-based</param>
/// <param name="column">the index of the column of the hyperlink, zero-based</param>
/// <returns>return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null</returns>
public IHyperlink GetHyperlink(int row, int column)
{
return _sh.GetHyperlink(row, column);
}
/// <summary>
/// Get a Hyperlink in this sheet located in a cell specified by {code addr}
/// </summary>
/// <param name="addr">The address of the cell containing the hyperlink</param>
/// <returns>return hyperlink if there is a hyperlink anchored at {@code addr}; otherwise returns {@code null}</returns>
public IHyperlink GetHyperlink(CellAddress addr)
{
return _sh.GetHyperlink(addr);
}
/**
* Get a list of Hyperlinks in this sheet
*
* @return Hyperlinks for the sheet
*/
public List<IHyperlink> GetHyperlinkList()
{
return _sh.GetHyperlinkList();
}
public IDrawing CreateDrawingPatriarch()
{
return _sh.CreateDrawingPatriarch();
}
public void CreateFreezePane(int colSplit, int rowSplit)
{
_sh.CreateFreezePane(colSplit, rowSplit);
}
public void CreateFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow)
{
_sh.CreateFreezePane(colSplit, rowSplit, leftmostColumn, topRow);
}
public IRow CreateRow(int rownum)
{
int maxrow = SpreadsheetVersion.EXCEL2007.LastRowIndex;
if (rownum < 0 || rownum > maxrow)
{
throw new ArgumentException("Invalid row number (" + rownum
+ ") outside allowable range (0.." + maxrow + ")");
}
// attempt to overwrite a row that is already flushed to disk
if (rownum <= _writer.NumberLastFlushedRow)
{
throw new ArgumentException(
"Attempting to write a row[" + rownum + "] " +
"in the range [0," + _writer.NumberLastFlushedRow + "] that is already written to disk.");
}
// attempt to overwrite a existing row in the input template
if (_sh.PhysicalNumberOfRows > 0 && rownum <= _sh.LastRowNum)
{
throw new ArgumentException(
"Attempting to write a row[" + rownum + "] " +
"in the range [0," + _sh.LastRowNum + "] that is already written to disk.");
}
SXSSFRow newRow = new SXSSFRow(this);
_rows[rownum] = newRow;
UpdateIndexWhenAdd(rownum);
allFlushed = false;
if (_randomAccessWindowSize >= 0 && _rows.Count > _randomAccessWindowSize)
{
try
{
FlushRows(_randomAccessWindowSize, false);
}
catch (IOException ioe)
{
throw new RuntimeException(ioe);
}
}
return newRow;
}
private void UpdateIndexWhenAdd(int rownum)
{
if (_FirstRowNum == -1 || rownum < _FirstRowNum)
{
_FirstRowNum = rownum;
}
if (rownum > _LastRowNum)
{
_LastRowNum = rownum;
}
}
public void CreateSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, PanePosition activePane)
{
_sh.CreateSplitPane(xSplitPos, ySplitPos, leftmostColumn, topRow, activePane);
}
/// <summary>
/// Returns cell comment for the specified row and column
/// </summary>
/// <param name="row">The row.</param>
/// <param name="column">The column.</param>
/// <returns>cell comment or <code>null</code> if not found</returns>
[Obsolete("deprecated as of 2015-11-23 (circa POI 3.14beta1). Use {@link #getCellComment(CellAddress)} instead.")]
public IComment GetCellComment(int row, int column)
{
return GetCellComment(new CellAddress(row, column));
}
/// <summary>
/// Returns cell comment for the specified location
/// </summary>
/// <param name="ref1">cell location</param>
/// <returns>return cell comment or null if not found</returns>
public IComment GetCellComment(CellAddress ref1)
{
return _sh.GetCellComment(ref1);
}
/// <summary>
/// Returns all cell comments on this sheet.
/// </summary>
/// <returns>return A Dictionary of each Comment in the sheet, keyed on the cell address where the comment is located.</returns>
public Dictionary<CellAddress, IComment> GetCellComments()
{
return _sh.GetCellComments();
}
public int GetColumnOutlineLevel(int columnIndex)
{
return _sh.GetColumnOutlineLevel(columnIndex);
}
public ICellStyle GetColumnStyle(int column)
{
return _sh.GetColumnStyle(column);
}
public int GetColumnWidth(int columnIndex)
{
return _sh.GetColumnWidth(columnIndex);
}
public float GetColumnWidthInPixels(int columnIndex)
{
return _sh.GetColumnWidthInPixels(columnIndex);
}
public IDataValidationHelper GetDataValidationHelper()
{
return _sh.GetDataValidationHelper();
}
public List<IDataValidation> GetDataValidations()
{
return _sh.GetDataValidations();
}
public IEnumerator GetEnumerator()
{
return (IEnumerator<IRow>)new SortedDictionary<int,SXSSFRow>(_rows).Values.GetEnumerator();
}
public double GetMargin(MarginType margin)
{
return _sh.GetMargin(margin);
}
public CellRangeAddress GetMergedRegion(int index)
{
return _sh.GetMergedRegion(index);
}
public IRow GetRow(int rownum)
{
if (_rows.ContainsKey(rownum))
return _rows[rownum];
else
return null;
}
public IEnumerator GetRowEnumerator()
{
return GetEnumerator();
}
public void GroupColumn(int fromColumn, int toColumn)
{
_sh.GroupColumn(fromColumn, toColumn);
}
//TODO: test
public void GroupRow(int fromRow, int toRow)
{
var groupRows = _rows.Where(kvp => kvp.Key >= fromRow && kvp.Key <= toRow + 1).Select(r => r.Value);
foreach (SXSSFRow row in groupRows)
{
int level = row.OutlineLevel + 1;
row.OutlineLevel = level;
if (level > outlineLevelRow) outlineLevelRow = level;
}
SetWorksheetOutlineLevelRow();
}
/**
* Set row groupings (like groupRow) in a stream-friendly manner
*
* <p>
* groupRows requires all rows in the group to be in the current window.
* This is not always practical. Instead use setRowOutlineLevel to
* explicitly set the group level. Level 1 is the top level group,
* followed by 2, etc. It is up to the user to ensure that level 2
* groups are correctly nested under level 1, etc.
* </p>
*
* @param rownum index of row to update (0-based)
* @param level outline level (greater than 0)
*/
public void SetRowOutlineLevel(int rownum, int level)
{
SXSSFRow row = _rows[rownum];
row.OutlineLevel = level;
if (level > 0 && level > outlineLevelRow)
{
outlineLevelRow = level;
SetWorksheetOutlineLevelRow();
}
}
private void SetWorksheetOutlineLevelRow()
{
var ct = _sh.GetCTWorksheet();
var pr = ct.IsSetSheetFormatPr() ?
ct.sheetFormatPr :
ct.AddNewSheetFormatPr();
if (outlineLevelRow > 0) pr.outlineLevelRow = (byte)outlineLevelRow;
}
public bool IsColumnBroken(int column)
{
return _sh.IsColumnBroken(column);
}
public bool IsColumnHidden(int columnIndex)
{
return _sh.IsColumnHidden(columnIndex);
}
public bool IsMergedRegion(CellRangeAddress mergedRegion)
{
throw new NotImplementedException();
}
public bool IsRowBroken(int row)
{
return _sh.IsRowBroken(row);
}
public void ProtectSheet(string password)
{
_sh.ProtectSheet(password);
}
public ICellRange<ICell> RemoveArrayFormula(ICell cell)
{
return _sh.RemoveArrayFormula(cell);
}
public void RemoveColumnBreak(int column)
{
_sh.RemoveColumnBreak(column);
}
public void RemoveMergedRegion(int index)
{
_sh.RemoveMergedRegion(index);
}
/**
* Removes a merged region of cells (hence letting them free)
*
* @param indices of the regions to unmerge
*/
public void RemoveMergedRegions(IList<int> indices)
{
_sh.RemoveMergedRegions(indices);
}
public void RemoveRow(IRow row)
{
if (row == null)
{
throw new ArgumentException("Invalid row (null)");
}
if (row.Sheet != this)
{
throw new ArgumentException("Specified row does not belong to this sheet");
}
List<int> toRemove = new List<int>();
foreach(var kv in _rows)
{
if(kv.Value == row)
{
toRemove.Add(kv.Key);
}
}
var invalidatedFirst = false;
var invalidatedLast = false;
foreach(var key in toRemove)
{
if (key == _FirstRowNum)
{
invalidatedFirst = true;
}
if (key >= (_LastRowNum -1))
{
invalidatedLast = true;
}
_rows.Remove(key);
}
if (invalidatedFirst)
{
InvalidateFirstRowNum();
}
if (invalidatedLast)
{
InvalidateLastRowNum();
}
}
private void InvalidateFirstRowNum()
{
if (_rows.Count == 0)
{
_FirstRowNum = -1;
}
else
{
_FirstRowNum = _rows.Keys.Min();
}
}
private void InvalidateLastRowNum()
{
if (_rows.Count == 0)
{
_LastRowNum = -1;
}
else
{
_LastRowNum = _rows.Keys.Max();
}
}
public void RemoveRowBreak(int row)
{
_sh.RemoveRowBreak(row);
}
public void SetActive(bool value)
{
throw new NotImplementedException();
}
public void SetActiveCell(int row, int column)
{
throw new NotImplementedException();
}
public void SetActiveCellRange(List<CellRangeAddress8Bit> cellranges, int activeRange, int activeRow, int activeColumn)
{
throw new NotImplementedException();
}