@@ -13,21 +13,19 @@ static void Main(string[] args)
1313 string fileName = "Report.xlsx" ;
1414
1515 //Split the Excel document
16- SplitExcelDocument ( inputPath + fileName ) ;
16+ SplitExcelDocument ( Path . GetFullPath ( inputPath + fileName ) ) ;
1717 }
1818 /// <summary>
1919 /// Split the Excel document from the given path
2020 /// </summary>
2121 /// <param name="filePath">Excel file path</param>
2222 private static void SplitExcelDocument ( string filePath )
2323 {
24- FileStream inputData = new FileStream ( filePath , FileMode . Open , FileAccess . ReadWrite ) ;
25-
2624 using ( ExcelEngine excelEngine = new ExcelEngine ( ) )
2725 {
2826 IApplication application = excelEngine . Excel ;
2927 application . DefaultVersion = ExcelVersion . Xlsx ;
30- IWorkbook workbook = application . Workbooks . Open ( inputData ) ;
28+ IWorkbook workbook = application . Workbooks . Open ( filePath ) ;
3129 IWorksheets worksheets = workbook . Worksheets ;
3230
3331 workbook . Version = ExcelVersion . Xlsx ;
@@ -38,9 +36,7 @@ private static void SplitExcelDocument(string filePath)
3836 IWorkbook newBook = application . Workbooks . Create ( 0 ) ;
3937 newBook . Worksheets . AddCopy ( worksheet ) ;
4038
41- FileStream outputData = new FileStream ( outputPath + worksheet . Name + ".xlsx" , FileMode . Create , FileAccess . ReadWrite ) ;
42- newBook . SaveAs ( outputData ) ;
43- outputData . Close ( ) ;
39+ newBook . SaveAs ( Path . GetFullPath ( outputPath + worksheet . Name + ".xlsx" ) ) ;
4440 }
4541 }
4642 }
0 commit comments