@@ -429,27 +429,27 @@ public IXLRange RangeFromFullAddress(String rangeAddress, out IXLWorksheet ws)
429
429
public void Save ( )
430
430
{
431
431
#if DEBUG
432
- Save ( true ) ;
432
+ Save ( true , false ) ;
433
433
#else
434
- Save ( false ) ;
434
+ Save ( false , false ) ;
435
435
#endif
436
436
}
437
437
438
438
/// <summary>
439
439
/// Saves the current workbook and optionally performs validation
440
440
/// </summary>
441
- public void Save ( bool validate )
441
+ public void Save ( Boolean validate , Boolean evaluateFormulae = false )
442
442
{
443
443
checkForWorksheetsPresent ( ) ;
444
444
if ( _loadSource == XLLoadSource . New )
445
445
throw new Exception ( "This is a new file, please use one of the SaveAs methods." ) ;
446
446
447
447
if ( _loadSource == XLLoadSource . Stream )
448
448
{
449
- CreatePackage ( _originalStream , false , _spreadsheetDocumentType , validate ) ;
449
+ CreatePackage ( _originalStream , false , _spreadsheetDocumentType , validate , evaluateFormulae ) ;
450
450
}
451
451
else
452
- CreatePackage ( _originalFile , _spreadsheetDocumentType , validate ) ;
452
+ CreatePackage ( _originalFile , _spreadsheetDocumentType , validate , evaluateFormulae ) ;
453
453
}
454
454
455
455
/// <summary>
@@ -458,16 +458,16 @@ public void Save(bool validate)
458
458
public void SaveAs ( String file )
459
459
{
460
460
#if DEBUG
461
- SaveAs ( file , true ) ;
461
+ SaveAs ( file , true , false ) ;
462
462
#else
463
- SaveAs ( file , false ) ;
463
+ SaveAs ( file , false , false ) ;
464
464
#endif
465
465
}
466
466
467
467
/// <summary>
468
468
/// Saves the current workbook to a file and optionally validates it.
469
469
/// </summary>
470
- public void SaveAs ( String file , Boolean validate )
470
+ public void SaveAs ( String file , Boolean validate , Boolean evaluateFormulae = false )
471
471
{
472
472
checkForWorksheetsPresent ( ) ;
473
473
PathHelper . CreateDirectory ( Path . GetDirectoryName ( file ) ) ;
@@ -476,14 +476,14 @@ public void SaveAs(String file, Boolean validate)
476
476
if ( File . Exists ( file ) )
477
477
File . Delete ( file ) ;
478
478
479
- CreatePackage ( file , GetSpreadsheetDocumentType ( file ) , validate ) ;
479
+ CreatePackage ( file , GetSpreadsheetDocumentType ( file ) , validate , evaluateFormulae ) ;
480
480
}
481
481
else if ( _loadSource == XLLoadSource . File )
482
482
{
483
483
if ( String . Compare ( _originalFile . Trim ( ) , file . Trim ( ) , true ) != 0 )
484
484
File . Copy ( _originalFile , file , true ) ;
485
485
486
- CreatePackage ( file , GetSpreadsheetDocumentType ( file ) , validate ) ;
486
+ CreatePackage ( file , GetSpreadsheetDocumentType ( file ) , validate , evaluateFormulae ) ;
487
487
}
488
488
else if ( _loadSource == XLLoadSource . Stream )
489
489
{
@@ -493,7 +493,7 @@ public void SaveAs(String file, Boolean validate)
493
493
{
494
494
CopyStream ( _originalStream , fileStream ) ;
495
495
//fileStream.Position = 0;
496
- CreatePackage ( fileStream , false , _spreadsheetDocumentType , validate ) ;
496
+ CreatePackage ( fileStream , false , _spreadsheetDocumentType , validate , evaluateFormulae ) ;
497
497
fileStream . Close ( ) ;
498
498
}
499
499
}
@@ -531,16 +531,16 @@ private void checkForWorksheetsPresent()
531
531
public void SaveAs ( Stream stream )
532
532
{
533
533
#if DEBUG
534
- SaveAs ( stream , true ) ;
534
+ SaveAs ( stream , true , false ) ;
535
535
#else
536
- SaveAs ( stream , false ) ;
536
+ SaveAs ( stream , false , false ) ;
537
537
#endif
538
538
}
539
539
540
540
/// <summary>
541
541
/// Saves the current workbook to a stream and optionally validates it.
542
542
/// </summary>
543
- public void SaveAs ( Stream stream , Boolean validate )
543
+ public void SaveAs ( Stream stream , Boolean validate , Boolean evaluateFormulae = false )
544
544
{
545
545
checkForWorksheetsPresent ( ) ;
546
546
if ( _loadSource == XLLoadSource . New )
@@ -552,13 +552,13 @@ public void SaveAs(Stream stream, Boolean validate)
552
552
if ( stream . CanRead && stream . CanSeek && stream . CanWrite )
553
553
{
554
554
// all is fine the package can be created in a direct way
555
- CreatePackage ( stream , true , _spreadsheetDocumentType , validate ) ;
555
+ CreatePackage ( stream , true , _spreadsheetDocumentType , validate , evaluateFormulae ) ;
556
556
}
557
557
else
558
558
{
559
559
// the harder way
560
560
MemoryStream ms = new MemoryStream ( ) ;
561
- CreatePackage ( ms , true , _spreadsheetDocumentType , validate ) ;
561
+ CreatePackage ( ms , true , _spreadsheetDocumentType , validate , evaluateFormulae ) ;
562
562
// not really nessesary, because I changed CopyStream too.
563
563
// but for better understanding and if somebody in the future
564
564
// provide an changed version of CopyStream
@@ -573,15 +573,15 @@ public void SaveAs(Stream stream, Boolean validate)
573
573
CopyStream ( fileStream , stream ) ;
574
574
fileStream . Close ( ) ;
575
575
}
576
- CreatePackage ( stream , false , _spreadsheetDocumentType , validate ) ;
576
+ CreatePackage ( stream , false , _spreadsheetDocumentType , validate , evaluateFormulae ) ;
577
577
}
578
578
else if ( _loadSource == XLLoadSource . Stream )
579
579
{
580
580
_originalStream . Position = 0 ;
581
581
if ( _originalStream != stream )
582
582
CopyStream ( _originalStream , stream ) ;
583
583
584
- CreatePackage ( stream , false , _spreadsheetDocumentType , validate ) ;
584
+ CreatePackage ( stream , false , _spreadsheetDocumentType , validate , evaluateFormulae ) ;
585
585
}
586
586
}
587
587
0 commit comments