File tree Expand file tree Collapse file tree 5 files changed +11
-41
lines changed 
Pivot Charts/Create Pivot Chart/.NET/Create Pivot Chart/Create Pivot Chart 
Apply Scenario/.NET/Apply Scenario/Apply Scenario 
Create Scenarios/.NET/Create Scenarios/Create Scenarios 
Hide Scenario/.NET/Hide Scenario/Hide Scenario 
Protect Scenario/.NET/Protect Scenario/Protect Scenario Expand file tree Collapse file tree 5 files changed +11
-41
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,7 @@ static void Main(string[] args)
1111            { 
1212                IApplication  application  =  excelEngine . Excel ; 
1313                application . DefaultVersion  =  ExcelVersion . Xlsx ; 
14-                 FileStream  inputStream  =  new  FileStream ( Path . GetFullPath ( @"Data/InputTemplate.xlsx" ) ,  FileMode . Open ,  FileAccess . Read ) ; 
15-                 IWorkbook  workbook  =  application . Workbooks . Open ( inputStream ) ; 
14+                 IWorkbook  workbook  =  application . Workbooks . Open ( Path . GetFullPath ( @"Data/InputTemplate.xlsx" ) ) ; 
1615                IWorksheet  worksheet  =  workbook . Worksheets [ 1 ] ; 
1716                IPivotTable  pivotTable  =  worksheet . PivotTables [ 0 ] ; 
1817
@@ -34,13 +33,8 @@ static void Main(string[] args)
3433
3534                #region Save
3635                //Saving the workbook 
37-                 FileStream  outputStream  =  new  FileStream ( Path . GetFullPath ( "Output/PivotChart.xlsx" ) ,  FileMode . Create ,  FileAccess . Write ) ; 
38-                 workbook . SaveAs ( outputStream ) ; 
36+ 				workbook . SaveAs ( Path . GetFullPath ( "Output/PivotChart.xlsx" ) ) ; 
3937                #endregion
40- 
41-                 //Dispose streams 
42-                 outputStream . Dispose ( ) ; 
43-                 inputStream . Dispose ( ) ; 
4438            } 
4539        } 
4640    } 
Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ static void Main(string[] args)
1313                IApplication  application  =  excelEngine . Excel ; 
1414                application . DefaultVersion  =  ExcelVersion . Xlsx ; 
1515
16-                 FileStream  inputStream  =  new  FileStream ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  FileMode . Open ,  FileAccess . Read ) ; 
17-                 IWorkbook  workbook  =  application . Workbooks . Open ( inputStream ,  ExcelOpenType . Automatic ) ; 
18-                 inputStream . Dispose ( ) ; 
16+                 IWorkbook  workbook  =  application . Workbooks . Open ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  ExcelOpenType . Automatic ) ; 
1917
2018                IWorksheet  worksheet  =  workbook . Worksheets [ 0 ] ; 
2119
@@ -33,11 +31,8 @@ static void Main(string[] args)
3331
3432                    newSheet . Name  =  scenarios [ pos ] . Name ; 
3533
36-                     //Saving the new workbook as a stream 
37-                     using  ( FileStream  stream  =  new  FileStream ( Path . GetFullPath ( @"Output/"  +  scenarios [ pos ] . Name  +  ".xlsx" ) ,  FileMode . Create ,  FileAccess . ReadWrite ) ) 
38-                     { 
39-                         newBook . SaveAs ( stream ) ; 
40-                     } 
34+                     //Saving the new workbook 
35+                     newBook . SaveAs ( Path . GetFullPath ( @"Output/"  +  scenarios [ pos ] . Name  +  ".xlsx" ) ) ; 
4136
4237                    //To restore the cell values from the previous scenario results 
4338                    scenarios [ "Current % of Change" ] . Show ( ) ; 
Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ static void Main(string[] args)
1313                IApplication  application  =  excelEngine . Excel ; 
1414                application . DefaultVersion  =  ExcelVersion . Xlsx ; 
1515
16-                 FileStream  inputStream  =  new  FileStream ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  FileMode . Open ,  FileAccess . Read ) ; 
17-                 IWorkbook  workbook  =  application . Workbooks . Open ( inputStream ,  ExcelOpenType . Automatic ) ; 
18-                 inputStream . Dispose ( ) ; 
16+                 IWorkbook  workbook  =  application . Workbooks . Open ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  ExcelOpenType . Automatic ) ; 
1917
2018                IWorksheet  worksheet  =  workbook . Worksheets [ 0 ] ; 
2119
@@ -40,12 +38,8 @@ static void Main(string[] args)
4038
4139                #region Save
4240                //Saving the workbook 
43-                 FileStream  outputStream  =  new  FileStream ( Path . GetFullPath ( "Output/CreateScenarios.xlsx" ) ,  FileMode . Create ,  FileAccess . Write ) ; 
44-                 workbook . SaveAs ( outputStream ) ; 
41+                 workbook . SaveAs ( Path . GetFullPath ( "Output/CreateScenarios.xlsx" ) ) ; 
4542                #endregion
46- 
47-                 //Dispose streams 
48-                 outputStream . Dispose ( ) ; 
4943            } 
5044        } 
5145    } 
Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ static void Main(string[] args)
1313                IApplication  application  =  excelEngine . Excel ; 
1414                application . DefaultVersion  =  ExcelVersion . Xlsx ; 
1515
16-                 FileStream  inputStream  =  new  FileStream ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  FileMode . Open ,  FileAccess . Read ) ; 
17-                 IWorkbook  workbook  =  application . Workbooks . Open ( inputStream ,  ExcelOpenType . Automatic ) ; 
18-                 inputStream . Dispose ( ) ; 
16+                 IWorkbook  workbook  =  application . Workbooks . Open ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  ExcelOpenType . Automatic ) ; 
1917
2018                IWorksheet  worksheet  =  workbook . Worksheets [ 0 ] ; 
2119
@@ -30,13 +28,8 @@ static void Main(string[] args)
3028
3129                #region Save
3230                //Saving the workbook 
33-                 FileStream  outputStream  =  new  FileStream ( Path . GetFullPath ( "Output/HideScenario.xlsx" ) ,  FileMode . Create ,  FileAccess . Write ) ; 
34-                 workbook . SaveAs ( outputStream ) ; 
31+                 workbook . SaveAs ( Path . GetFullPath ( "Output/HideScenario.xlsx" ) ) ; 
3532                #endregion
36- 
37-                 //Dispose streams 
38-                 outputStream . Dispose ( ) ; 
39- 
4033            } 
4134        } 
4235    } 
Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ static void Main(string[] args)
1313                IApplication  application  =  excelEngine . Excel ; 
1414                application . DefaultVersion  =  ExcelVersion . Xlsx ; 
1515
16-                 FileStream  inputStream  =  new  FileStream ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  FileMode . Open ,  FileAccess . Read ) ; 
17-                 IWorkbook  workbook  =  application . Workbooks . Open ( inputStream ,  ExcelOpenType . Automatic ) ; 
18-                 inputStream . Dispose ( ) ; 
16+                 IWorkbook  workbook  =  application . Workbooks . Open ( Path . GetFullPath ( @"Data/WhatIfAnalysisTemplate.xlsx" ) ,  ExcelOpenType . Automatic ) ; 
1917
2018                IWorksheet  worksheet  =  workbook . Worksheets [ 0 ] ; 
2119
@@ -30,13 +28,9 @@ static void Main(string[] args)
3028
3129                #region Save
3230                //Saving the workbook 
33-                 FileStream  outputStream  =  new  FileStream ( Path . GetFullPath ( "Output/ProtectScenario.xlsx" ) ,  FileMode . Create ,  FileAccess . Write ) ; 
34-                 workbook . SaveAs ( outputStream ) ; 
31+                 workbook . SaveAs ( Path . GetFullPath ( "Output/ProtectScenario.xlsx" ) ) ; 
3532                #endregion
3633
37-                 //Dispose streams 
38-                 outputStream . Dispose ( ) ; 
39- 
4034            } 
4135        } 
4236    } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments