diff --git a/Excel to PDF/Automatic Layout/.NET/Automatic Layout/Automatic Layout/Program.cs b/Excel to PDF/Automatic Layout/.NET/Automatic Layout/Automatic Layout/Program.cs index 86e399c7..fa6fc84c 100644 --- a/Excel to PDF/Automatic Layout/.NET/Automatic Layout/Automatic Layout/Program.cs +++ b/Excel to PDF/Automatic Layout/.NET/Automatic Layout/Automatic Layout/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,19 +29,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Automatic.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/Automatic.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } -} - - - - - +} \ No newline at end of file diff --git a/Excel to PDF/Blank Page to PDF/.NET/Blank Page to PDF/Blank Page to PDF/Program.cs b/Excel to PDF/Blank Page to PDF/.NET/Blank Page to PDF/Blank Page to PDF/Program.cs index bde5bcf1..6cdd596d 100644 --- a/Excel to PDF/Blank Page to PDF/.NET/Blank Page to PDF/Blank Page to PDF/Program.cs +++ b/Excel to PDF/Blank Page to PDF/.NET/Blank Page to PDF/Blank Page to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/BlankPageToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/BlankPageToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Blank Sheet to PDF/.NET/Blank Sheet to PDF/Blank Sheet to PDF/Program.cs b/Excel to PDF/Blank Sheet to PDF/.NET/Blank Sheet to PDF/Blank Sheet to PDF/Program.cs index f1287ef8..d828f3b3 100644 --- a/Excel to PDF/Blank Sheet to PDF/.NET/Blank Sheet to PDF/Blank Sheet to PDF/Program.cs +++ b/Excel to PDF/Blank Sheet to PDF/.NET/Blank Sheet to PDF/Blank Sheet to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/BlankSheetToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/BlankSheetToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Bookmarks in PDF/.NET/Bookmarks in PDF/Bookmarks in PDF/Program.cs b/Excel to PDF/Bookmarks in PDF/.NET/Bookmarks in PDF/Bookmarks in PDF/Program.cs index 338fefc9..6a8a0c7d 100644 --- a/Excel to PDF/Bookmarks in PDF/.NET/Bookmarks in PDF/Bookmarks in PDF/Program.cs +++ b/Excel to PDF/Bookmarks in PDF/.NET/Bookmarks in PDF/Bookmarks in PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/BookmarksInPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/BookmarksInPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Chart to PDF/.NET/Chart to PDF/Chart to PDF/Program.cs b/Excel to PDF/Chart to PDF/.NET/Chart to PDF/Chart to PDF/Program.cs index 37230373..902dde5f 100644 --- a/Excel to PDF/Chart to PDF/.NET/Chart to PDF/Chart to PDF/Program.cs +++ b/Excel to PDF/Chart to PDF/.NET/Chart to PDF/Chart to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; @@ -27,13 +26,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/ChartToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/ChartToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Comments in Place to PDF/.NET/Comments in Place to PDF/Comments in Place to PDF/Program.cs b/Excel to PDF/Comments in Place to PDF/.NET/Comments in Place to PDF/Comments in Place to PDF/Program.cs index 537494b3..9869be81 100644 --- a/Excel to PDF/Comments in Place to PDF/.NET/Comments in Place to PDF/Comments in Place to PDF/Program.cs +++ b/Excel to PDF/Comments in Place to PDF/.NET/Comments in Place to PDF/Comments in Place to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Set print location to comments @@ -28,13 +27,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CommentsInPlaceToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/CommentsInPlaceToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Comments to PDF at End/.NET/Comments to PDF at End/Comments to PDF at End/Program.cs b/Excel to PDF/Comments to PDF at End/.NET/Comments to PDF at End/Comments to PDF at End/Program.cs index 9047875a..765916b8 100644 --- a/Excel to PDF/Comments to PDF at End/.NET/Comments to PDF at End/Comments to PDF at End/Program.cs +++ b/Excel to PDF/Comments to PDF at End/.NET/Comments to PDF at End/Comments to PDF at End/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Set print location to comments @@ -28,13 +27,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CommentsToPDFAtEnd.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/CommentsToPDFAtEnd.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Complex Script to PDF/.NET/Complex Script to PDF/Complex Script to PDF/Program.cs b/Excel to PDF/Complex Script to PDF/.NET/Complex Script to PDF/Complex Script to PDF/Program.cs index 17981581..af8ab0f4 100644 --- a/Excel to PDF/Complex Script to PDF/.NET/Complex Script to PDF/Complex Script to PDF/Program.cs +++ b/Excel to PDF/Complex Script to PDF/.NET/Complex Script to PDF/Complex Script to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/ComplexScriptToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/ComplexScriptToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Custom Paper Size/.NET/Custom Paper Size/Custom Paper Size/Program.cs b/Excel to PDF/Custom Paper Size/.NET/Custom Paper Size/Custom Paper Size/Program.cs index a500b7f9..dd839188 100644 --- a/Excel to PDF/Custom Paper Size/.NET/Custom Paper Size/Custom Paper Size/Program.cs +++ b/Excel to PDF/Custom Paper Size/.NET/Custom Paper Size/Custom Paper Size/Program.cs @@ -14,8 +14,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -31,13 +30,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CustomPaperSize.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/CustomPaperSize.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Custom Scaling/.NET/Custom Scaling/Custom Scaling/Program.cs b/Excel to PDF/Custom Scaling/.NET/Custom Scaling/Custom Scaling/Program.cs index cbfc9962..15ce93ef 100644 --- a/Excel to PDF/Custom Scaling/.NET/Custom Scaling/Custom Scaling/Program.cs +++ b/Excel to PDF/Custom Scaling/.NET/Custom Scaling/Custom Scaling/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CustomScaling.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/CustomScaling.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Document Properties to PDF/.NET/Document Properties to PDF/Document Properties to PDF/Program.cs b/Excel to PDF/Document Properties to PDF/.NET/Document Properties to PDF/Document Properties to PDF/Program.cs index 27e4c2ba..acaaca7e 100644 --- a/Excel to PDF/Document Properties to PDF/.NET/Document Properties to PDF/Document Properties to PDF/Program.cs +++ b/Excel to PDF/Document Properties to PDF/.NET/Document Properties to PDF/Document Properties to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/DocumentProperties.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/DocumentProperties.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Each Worksheet to PDF/.NET/Each Worksheet to PDF/Each Worksheet to PDF/Program.cs b/Excel to PDF/Each Worksheet to PDF/.NET/Each Worksheet to PDF/Each Worksheet to PDF/Program.cs index 77225399..4521f60a 100644 --- a/Excel to PDF/Each Worksheet to PDF/.NET/Each Worksheet to PDF/Each Worksheet to PDF/Program.cs +++ b/Excel to PDF/Each Worksheet to PDF/.NET/Each Worksheet to PDF/Each Worksheet to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIO renderer. XlsIORenderer renderer = new XlsIORenderer(); @@ -26,14 +25,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(sheet.Name +".pdf", FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(sheet.Name +".pdf"); #endregion - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); - System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo(sheet.Name + ".pdf") { diff --git a/Excel to PDF/Embed Fonts in PDF/.NET/Embed Fonts in PDF/Embed Fonts in PDF/Program.cs b/Excel to PDF/Embed Fonts in PDF/.NET/Embed Fonts in PDF/Embed Fonts in PDF/Program.cs index fff62225..12a05d64 100644 --- a/Excel to PDF/Embed Fonts in PDF/.NET/Embed Fonts in PDF/Embed Fonts in PDF/Program.cs +++ b/Excel to PDF/Embed Fonts in PDF/.NET/Embed Fonts in PDF/Embed Fonts in PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/EmbedFonts.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/EmbedFonts.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Empty Excel to PDF/.NET/Empty Excel to PDF/Empty Excel to PDF/Program.cs b/Excel to PDF/Empty Excel to PDF/.NET/Empty Excel to PDF/Empty Excel to PDF/Program.cs index d2c4f986..1a73da03 100644 --- a/Excel to PDF/Empty Excel to PDF/.NET/Empty Excel to PDF/Empty Excel to PDF/Program.cs +++ b/Excel to PDF/Empty Excel to PDF/.NET/Empty Excel to PDF/Empty Excel to PDF/Program.cs @@ -28,17 +28,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/EmptyExcelToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/EmptyExcelToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); } } } -} - - - - +} \ No newline at end of file diff --git a/Excel to PDF/Fallback fonts based on script type/.NET/Fallback_fonts_based_on_scripttype/Fallback_fonts_based_on_scripttype/Program.cs b/Excel to PDF/Fallback fonts based on script type/.NET/Fallback_fonts_based_on_scripttype/Fallback_fonts_based_on_scripttype/Program.cs index 1392767e..dea653d8 100644 --- a/Excel to PDF/Fallback fonts based on script type/.NET/Fallback_fonts_based_on_scripttype/Fallback_fonts_based_on_scripttype/Program.cs +++ b/Excel to PDF/Fallback fonts based on script type/.NET/Fallback_fonts_based_on_scripttype/Fallback_fonts_based_on_scripttype/Program.cs @@ -14,8 +14,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); @@ -38,13 +37,11 @@ static void Main(string[] args) //Convert Excel document into PDF document PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Save the converted PDF document to stream. - FileStream stream = new FileStream("Sample.pdf", FileMode.Create, FileAccess.ReadWrite); - pdfDocument.Save(stream); + //Save the converted PDF document + pdfDocument.Save("Sample.pdf"); //Close and Dispose workbook.Close(); - stream.Dispose(); } } } diff --git a/Excel to PDF/Fallback fonts for unicode range/.NET/Fallback_fonts_for_unicode_range/Fallback_fonts_for_unicode_range/Program.cs b/Excel to PDF/Fallback fonts for unicode range/.NET/Fallback_fonts_for_unicode_range/Fallback_fonts_for_unicode_range/Program.cs index 5a460499..d41dc488 100644 --- a/Excel to PDF/Fallback fonts for unicode range/.NET/Fallback_fonts_for_unicode_range/Fallback_fonts_for_unicode_range/Program.cs +++ b/Excel to PDF/Fallback fonts for unicode range/.NET/Fallback_fonts_for_unicode_range/Fallback_fonts_for_unicode_range/Program.cs @@ -14,8 +14,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); @@ -39,12 +38,10 @@ static void Main(string[] args) PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); //Excel to PDF - Stream stream = new FileStream("Sample.pdf", FileMode.Create, FileAccess.ReadWrite); - pdfDocument.Save(stream); + pdfDocument.Save("Sample.pdf"); //Close and Dispose workbook.Close(); - stream.Dispose(); } } } diff --git a/Excel to PDF/Fit All Columns On One Page/.NET/Fit All Columns On One Page/Fit All Columns On One Page/Program.cs b/Excel to PDF/Fit All Columns On One Page/.NET/Fit All Columns On One Page/Fit All Columns On One Page/Program.cs index 3807a02b..56edfb6e 100644 --- a/Excel to PDF/Fit All Columns On One Page/.NET/Fit All Columns On One Page/Fit All Columns On One Page/Program.cs +++ b/Excel to PDF/Fit All Columns On One Page/.NET/Fit All Columns On One Page/Fit All Columns On One Page/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,19 +29,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/FitAllColumnsOnOnePage.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/FitAllColumnsOnOnePage.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } -} - - - - - +} \ No newline at end of file diff --git a/Excel to PDF/Fit All Rows On One Page/.NET/Fit All Rows On One Page/Fit All Rows On One Page/Program.cs b/Excel to PDF/Fit All Rows On One Page/.NET/Fit All Rows On One Page/Fit All Rows On One Page/Program.cs index 96f5a9f2..9f47bd0d 100644 --- a/Excel to PDF/Fit All Rows On One Page/.NET/Fit All Rows On One Page/Fit All Rows On One Page/Program.cs +++ b/Excel to PDF/Fit All Rows On One Page/.NET/Fit All Rows On One Page/Fit All Rows On One Page/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,19 +29,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/FitAllRowsOnOnePage.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/FitAllRowsOnOnePage.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } -} - - - - - +} \ No newline at end of file diff --git a/Excel to PDF/Fit Sheet On One Page/.NET/Fit Sheet On One Page/Fit Sheet On One Page/Program.cs b/Excel to PDF/Fit Sheet On One Page/.NET/Fit Sheet On One Page/Fit Sheet On One Page/Program.cs index 4583e6a0..b0c280d8 100644 --- a/Excel to PDF/Fit Sheet On One Page/.NET/Fit Sheet On One Page/Fit Sheet On One Page/Program.cs +++ b/Excel to PDF/Fit Sheet On One Page/.NET/Fit Sheet On One Page/Fit Sheet On One Page/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,19 +29,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/FitSheetOnOnePage.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/FitSheetOnOnePage.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } } - - - - - diff --git a/Excel to PDF/Gridlines in PDF/.NET/Gridlines in PDF/Gridlines in PDF/Program.cs b/Excel to PDF/Gridlines in PDF/.NET/Gridlines in PDF/Gridlines in PDF/Program.cs index 7b47a419..c64adf3b 100644 --- a/Excel to PDF/Gridlines in PDF/.NET/Gridlines in PDF/Gridlines in PDF/Program.cs +++ b/Excel to PDF/Gridlines in PDF/.NET/Gridlines in PDF/Gridlines in PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Gridlines.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/Gridlines.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Initialize default fallback fonts/.NET/Initialize_default-fallback_fonts/Initialize_default-fallback_fonts/Program.cs b/Excel to PDF/Initialize default fallback fonts/.NET/Initialize_default-fallback_fonts/Initialize_default-fallback_fonts/Program.cs index 11e31d59..c82c8710 100644 --- a/Excel to PDF/Initialize default fallback fonts/.NET/Initialize_default-fallback_fonts/Initialize_default-fallback_fonts/Program.cs +++ b/Excel to PDF/Initialize default fallback fonts/.NET/Initialize_default-fallback_fonts/Initialize_default-fallback_fonts/Program.cs @@ -12,8 +12,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); @@ -27,13 +26,11 @@ static void Main(string[] args) //Convert Excel document into PDF document PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Save the converted PDF document to stream. - FileStream stream = new FileStream("Sample.pdf", FileMode.Create, FileAccess.ReadWrite); - pdfDocument.Save(stream); + //Save the converted PDF document + pdfDocument.Save("Sample.pdf"); //Close and Dispose workbook.Close(); - stream.Dispose(); } } } diff --git a/Excel to PDF/Modify the existing fallback fonts/.NET/Modify_the_existing_fallback_fonts/Modify_the_existing_fallback_fonts/Program.cs b/Excel to PDF/Modify the existing fallback fonts/.NET/Modify_the_existing_fallback_fonts/Modify_the_existing_fallback_fonts/Program.cs index a80a511e..3d361089 100644 --- a/Excel to PDF/Modify the existing fallback fonts/.NET/Modify_the_existing_fallback_fonts/Modify_the_existing_fallback_fonts/Program.cs +++ b/Excel to PDF/Modify the existing fallback fonts/.NET/Modify_the_existing_fallback_fonts/Modify_the_existing_fallback_fonts/Program.cs @@ -14,8 +14,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); @@ -37,13 +36,11 @@ static void Main(string[] args) //Convert Excel document into PDF document PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Save the PDF document to stream - FileStream stream = new FileStream("Sample.pdf", FileMode.Create, FileAccess.ReadWrite); - pdfDocument.Save(stream); + //Save the PDF document + pdfDocument.Save("Sample.pdf"); //Close and Dispose workbook.Close(); - stream.Dispose(); } } } diff --git a/Excel to PDF/Multiple Excel to PDF/.NET/Multiple Excel to PDF/Multiple Excel to PDF/Program.cs b/Excel to PDF/Multiple Excel to PDF/.NET/Multiple Excel to PDF/Multiple Excel to PDF/Program.cs index 52e3b01c..17c8a281 100644 --- a/Excel to PDF/Multiple Excel to PDF/.NET/Multiple Excel to PDF/Multiple Excel to PDF/Program.cs +++ b/Excel to PDF/Multiple Excel to PDF/.NET/Multiple Excel to PDF/Multiple Excel to PDF/Program.cs @@ -13,11 +13,9 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream1 = new FileStream(Path.GetFullPath(@"Data/Template1.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook1 = application.Workbooks.Open(inputStream1); + IWorkbook workbook1 = application.Workbooks.Open(Path.GetFullPath(@"Data/Template1.xlsx")); - FileStream inputStream2 = new FileStream(Path.GetFullPath(@"Data/Template2.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook2 = application.Workbooks.Open(inputStream2); + IWorkbook workbook2 = application.Workbooks.Open(Path.GetFullPath(@"Data/Template2.xlsx")); //Initialize XlsIORenderer XlsIORenderer renderer = new XlsIORenderer(); @@ -36,20 +34,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/MultipleExcelToPDF.pdf"), FileMode.Create, FileAccess.Write); - newDocument.Save(outputStream); + newDocument.Save(Path.GetFullPath("Output/MultipleExcelToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream1.Dispose(); - inputStream2.Dispose(); } } } } - - - - - diff --git a/Excel to PDF/No Comments in PDF/.NET/No Comments in PDF/No Comments in PDF/Program.cs b/Excel to PDF/No Comments in PDF/.NET/No Comments in PDF/No Comments in PDF/Program.cs index 22445b7e..d87783ee 100644 --- a/Excel to PDF/No Comments in PDF/.NET/No Comments in PDF/No Comments in PDF/Program.cs +++ b/Excel to PDF/No Comments in PDF/.NET/No Comments in PDF/No Comments in PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Set print location to comments @@ -28,13 +27,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/NoCommentsInPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/NoCommentsInPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/No Scaling/.NET/No Scaling/No Scaling/Program.cs b/Excel to PDF/No Scaling/.NET/No Scaling/No Scaling/Program.cs index 802fabaa..b5724267 100644 --- a/Excel to PDF/No Scaling/.NET/No Scaling/No Scaling/Program.cs +++ b/Excel to PDF/No Scaling/.NET/No Scaling/No Scaling/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/NoScaling.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/NoScaling.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/PDF Conformance/.NET/PDF Conformance/PDF Conformance/Program.cs b/Excel to PDF/PDF Conformance/.NET/PDF Conformance/PDF Conformance/Program.cs index 8f66cd69..336fd9b4 100644 --- a/Excel to PDF/PDF Conformance/.NET/PDF Conformance/PDF Conformance/Program.cs +++ b/Excel to PDF/PDF Conformance/.NET/PDF Conformance/PDF Conformance/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIO renderer. XlsIORenderer renderer = new XlsIORenderer(); @@ -30,19 +29,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/PDFConformance.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/PDFConformance.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } -} - - - - - +} \ No newline at end of file diff --git a/Excel to PDF/Quality Image in PDF/.NET/Quality Image in PDF/Quality Image in PDF/Program.cs b/Excel to PDF/Quality Image in PDF/.NET/Quality Image in PDF/Quality Image in PDF/Program.cs index 10e8e705..b8a20441 100644 --- a/Excel to PDF/Quality Image in PDF/.NET/Quality Image in PDF/Quality Image in PDF/Program.cs +++ b/Excel to PDF/Quality Image in PDF/.NET/Quality Image in PDF/Quality Image in PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -30,13 +29,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/QualityImageInPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/QualityImageInPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Selected Worksheets to PDF/.NET/Selected Worksheets to PDF/Selected Worksheets to PDF/Program.cs b/Excel to PDF/Selected Worksheets to PDF/.NET/Selected Worksheets to PDF/Selected Worksheets to PDF/Program.cs index f2eaa41a..37afa1e9 100644 --- a/Excel to PDF/Selected Worksheets to PDF/.NET/Selected Worksheets to PDF/Selected Worksheets to PDF/Program.cs +++ b/Excel to PDF/Selected Worksheets to PDF/.NET/Selected Worksheets to PDF/Selected Worksheets to PDF/Program.cs @@ -15,8 +15,7 @@ static void Main(string[] args) application.DefaultVersion = ExcelVersion.Xlsx; //Open an Excel document - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Get the first worksheet IWorksheet worksheet1 = workbook.Worksheets[0]; @@ -41,19 +40,9 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/SelectedSheetsToPDF.pdf"), FileMode.Create, FileAccess.Write); - newDocument.Save(outputStream); + newDocument.Save(Path.GetFullPath("Output/SelectedSheetsToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } -} - - - - - +} \ No newline at end of file diff --git a/Excel to PDF/Show Header Footer in PDF/.NET/Show Header Footer In PDF/Show Header Footer In PDF/Program.cs b/Excel to PDF/Show Header Footer in PDF/.NET/Show Header Footer In PDF/Show Header Footer In PDF/Program.cs index a4590015..798fdb17 100644 --- a/Excel to PDF/Show Header Footer in PDF/.NET/Show Header Footer In PDF/Show Header Footer In PDF/Program.cs +++ b/Excel to PDF/Show Header Footer in PDF/.NET/Show Header Footer In PDF/Show Header Footer In PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIORendererSettings XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -33,13 +32,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HeaderFooterInPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/HeaderFooterInPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Warnings/.NET/Warnings/Warnings/Program.cs b/Excel to PDF/Warnings/.NET/Warnings/Warnings/Program.cs index 1203bf6d..25d2931d 100644 --- a/Excel to PDF/Warnings/.NET/Warnings/Warnings/Program.cs +++ b/Excel to PDF/Warnings/.NET/Warnings/Warnings/Program.cs @@ -14,8 +14,7 @@ static void Main(string[] args) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; //Open the Excel document to convert. - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize warning class to capture warnings during the conversion. Warning warning = new Warning(); @@ -37,14 +36,9 @@ static void Main(string[] args) { #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/ExceltoPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/ExceltoPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); } - inputStream.Dispose(); } } } @@ -61,8 +55,3 @@ public void ShowWarning(WarningInfo warning) public bool Cancel { get; set; } } } - - - - - diff --git a/Excel to PDF/Workbook to PDF/.NET/Workbook to PDF/Workbook to PDF/Program.cs b/Excel to PDF/Workbook to PDF/.NET/Workbook to PDF/Workbook to PDF/Program.cs index 1cfe6713..c2d40fa6 100644 --- a/Excel to PDF/Workbook to PDF/.NET/Workbook to PDF/Workbook to PDF/Program.cs +++ b/Excel to PDF/Workbook to PDF/.NET/Workbook to PDF/Workbook to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIO renderer. XlsIORenderer renderer = new XlsIORenderer(); @@ -24,13 +23,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/WorkbookToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/WorkbookToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Excel to PDF/Worksheet to PDF/.NET/Worksheet to PDF/Worksheet to PDF/Program.cs b/Excel to PDF/Worksheet to PDF/.NET/Worksheet to PDF/Worksheet to PDF/Program.cs index ae8e78d9..9bfc80c5 100644 --- a/Excel to PDF/Worksheet to PDF/.NET/Worksheet to PDF/Worksheet to PDF/Program.cs +++ b/Excel to PDF/Worksheet to PDF/.NET/Worksheet to PDF/Worksheet to PDF/Program.cs @@ -13,8 +13,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Initialize XlsIO renderer. @@ -25,13 +24,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/WorksheetToPDF.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/WorksheetToPDF.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Getting Started/ASP.NET Core/Convert Excel to PDF/Convert Excel to PDF/Controllers/HomeController.cs b/Getting Started/ASP.NET Core/Convert Excel to PDF/Convert Excel to PDF/Controllers/HomeController.cs index 3bcbf1d0..fc933396 100644 --- a/Getting Started/ASP.NET Core/Convert Excel to PDF/Convert Excel to PDF/Controllers/HomeController.cs +++ b/Getting Started/ASP.NET Core/Convert Excel to PDF/Convert Excel to PDF/Controllers/HomeController.cs @@ -30,8 +30,7 @@ public IActionResult ConvertExcelToPdf() application.DefaultVersion = ExcelVersion.Xlsx; //load an existing file - FileStream excelStream = new FileStream("Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIO renderer. XlsIORenderer renderer = new XlsIORenderer(); diff --git a/Getting Started/ASP.NET MVC/Convert Excel to PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs b/Getting Started/ASP.NET MVC/Convert Excel to PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs index 54d013e5..dd356a42 100644 --- a/Getting Started/ASP.NET MVC/Convert Excel to PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs +++ b/Getting Started/ASP.NET MVC/Convert Excel to PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs @@ -33,8 +33,7 @@ public ActionResult ConvertExcelToPdf() application.DefaultVersion = ExcelVersion.Xlsx; //Load an existing file - FileStream excelStream = new FileStream(Server.MapPath("~/App_Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open(Server.MapPath("~/App_Data/InputTemplate.xlsx")); //Initialize ExcelToPdfConverter ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); diff --git a/Getting Started/ASP.NET WebForms/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.aspx.cs b/Getting Started/ASP.NET WebForms/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.aspx.cs index ccf4600b..2ecd4222 100644 --- a/Getting Started/ASP.NET WebForms/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.aspx.cs +++ b/Getting Started/ASP.NET WebForms/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.aspx.cs @@ -18,8 +18,7 @@ protected void OnButtonClicked(object sender, EventArgs e) application.DefaultVersion = ExcelVersion.Xlsx; //Load an existing file - FileStream excelStream = new FileStream(Server.MapPath("~/App_Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open(Server.MapPath("~/App_Data/InputTemplate.xlsx")); //Initialize ExcelToPdfConverter ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); diff --git a/Getting Started/Azure App Service/Convert-Excel-to-PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs b/Getting Started/Azure App Service/Convert-Excel-to-PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs index fa9335bd..733157f6 100644 --- a/Getting Started/Azure App Service/Convert-Excel-to-PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs +++ b/Getting Started/Azure App Service/Convert-Excel-to-PDF/Convert-Excel-to-PDF/Controllers/HomeController.cs @@ -26,8 +26,7 @@ public IActionResult CreateDocument() { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); //Initialize XlsIO renderer. XlsIORenderer renderer = new XlsIORenderer(); diff --git a/Getting Started/Blazor/Server Side/Convert Excel to PDF/Convert-Excel-to-PDF/Data/ExcelService.cs b/Getting Started/Blazor/Server Side/Convert Excel to PDF/Convert-Excel-to-PDF/Data/ExcelService.cs index 58c07abb..c86ca910 100644 --- a/Getting Started/Blazor/Server Side/Convert Excel to PDF/Convert-Excel-to-PDF/Data/ExcelService.cs +++ b/Getting Started/Blazor/Server Side/Convert Excel to PDF/Convert-Excel-to-PDF/Data/ExcelService.cs @@ -14,29 +14,24 @@ public MemoryStream ConvertExceltoPDF() { IApplication application = excelEngine.Excel; - using (FileStream sourceStreamPath = new FileStream(@"wwwroot/InputTemplate.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - // Open the workbook. - IWorkbook workbook = application.Workbooks.Open(sourceStreamPath); + // Open the workbook. + IWorkbook workbook = application.Workbooks.Open(@"wwwroot/InputTemplate.xlsx"); - // Instantiate the Excel to PDF renderer. - XlsIORenderer renderer = new XlsIORenderer(); + // Instantiate the Excel to PDF renderer. + XlsIORenderer renderer = new XlsIORenderer(); - //Convert Excel document into PDF document - PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); + //Convert Excel document into PDF document + PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Create the MemoryStream to save the converted PDF. - MemoryStream pdfStream = new MemoryStream(); + //Create the MemoryStream to save the converted PDF. + MemoryStream pdfStream = new MemoryStream(); - //Save the converted PDF document to MemoryStream. - pdfDocument.Save(pdfStream); - pdfStream.Position = 0; + //Save the converted PDF document to MemoryStream. + pdfDocument.Save(pdfStream); + pdfStream.Position = 0; - return pdfStream; - - } + return pdfStream; } - } } } diff --git a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs index d6ab461c..d9f8f72e 100644 --- a/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs +++ b/Getting Started/Console/.NET Framework/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs @@ -13,8 +13,7 @@ public static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); //Initialize ExcelToPdfConverter ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); @@ -30,4 +29,4 @@ public static void Main(string[] args) } } } -} +} \ No newline at end of file diff --git a/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs index 77d6161d..39747eea 100644 --- a/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs +++ b/Getting Started/Console/.NET/ConvertExcelToPDF/ConvertExcelToPDF/Program.cs @@ -15,25 +15,16 @@ public static void Main(string[] args) application.DefaultVersion = ExcelVersion.Xlsx; //Load existing Excel file - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Sample.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Sample.xlsx")); //Convert to PDF XlsIORenderer renderer = new XlsIORenderer(); PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Create the MemoryStream to save the converted PDF - MemoryStream pdfStream = new MemoryStream(); - #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/Sample.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } } } diff --git a/Getting Started/Docker/Ubuntu/Convert Excel to PDF/Convert-Excel-to-PDF/Program.cs b/Getting Started/Docker/Ubuntu/Convert Excel to PDF/Convert-Excel-to-PDF/Program.cs index bf731cc8..0388d84e 100644 --- a/Getting Started/Docker/Ubuntu/Convert Excel to PDF/Convert-Excel-to-PDF/Program.cs +++ b/Getting Started/Docker/Ubuntu/Convert Excel to PDF/Convert-Excel-to-PDF/Program.cs @@ -15,8 +15,7 @@ static void Main(string[] args) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream excelStream = new FileStream("Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); //Initialize XlsIO renderer. XlsIORenderer renderer = new XlsIORenderer(); @@ -24,14 +23,9 @@ static void Main(string[] args) //Convert Excel document into PDF document PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Create the FileStream to save the converted PDF. - FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); - pdfDocument.Save(pdfStream); + //Save the converted PDF. + pdfDocument.Save("Output.pdf"); } } } -} - - - - +} \ No newline at end of file diff --git a/Getting Started/Linux/Convert Excel to PDF/Convert Excel to PDF/Program.cs b/Getting Started/Linux/Convert Excel to PDF/Convert Excel to PDF/Program.cs index 3497b835..52554647 100644 --- a/Getting Started/Linux/Convert Excel to PDF/Convert Excel to PDF/Program.cs +++ b/Getting Started/Linux/Convert Excel to PDF/Convert Excel to PDF/Program.cs @@ -14,26 +14,16 @@ static void Main(string[] args) application.DefaultVersion = ExcelVersion.Xlsx; //Load existing Excel file - FileStream inputStream = new FileStream("Data/Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Sample.xlsx")); //Convert to PDF XlsIORenderer renderer = new XlsIORenderer(); PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Create the MemoryStream to save the converted PDF. - MemoryStream pdfStream = new MemoryStream(); - #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/Sample.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); - } } } diff --git a/Getting Started/Mac/Convert Excel to PDF/Convert Excel to PDF/Program.cs b/Getting Started/Mac/Convert Excel to PDF/Convert Excel to PDF/Program.cs index 4ae2bd72..b4e0c0b2 100644 --- a/Getting Started/Mac/Convert Excel to PDF/Convert Excel to PDF/Program.cs +++ b/Getting Started/Mac/Convert Excel to PDF/Convert Excel to PDF/Program.cs @@ -14,26 +14,16 @@ static void Main(string[] args) application.DefaultVersion = ExcelVersion.Xlsx; //Load existing Excel file - FileStream inputStream = new FileStream("Data/Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Sample.xlsx")); //Convert to PDF XlsIORenderer renderer = new XlsIORenderer(); PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Create the MemoryStream to save the converted PDF. - MemoryStream pdfStream = new MemoryStream(); - #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.pdf"), FileMode.Create, FileAccess.Write); - pdfDocument.Save(outputStream); + pdfDocument.Save(Path.GetFullPath("Output/Sample.pdf")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); - } } } diff --git a/Getting Started/UWP/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.xaml.cs b/Getting Started/UWP/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.xaml.cs index 3e7f62c2..4494afcb 100644 --- a/Getting Started/UWP/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.xaml.cs +++ b/Getting Started/UWP/Convert Excel to PDF/Convert-Excel-to-PDF/MainPage.xaml.cs @@ -34,26 +34,24 @@ private async void OnButtonClicked(object sender, RoutedEventArgs e) //Load an existing file Assembly assembly = typeof(App).GetTypeInfo().Assembly; - using (Stream inputStream = assembly.GetManifestResourceStream("Convert_Excel_to_PDF.InputTemplate.xlsx")) - { - IWorkbook workbook =application.Workbooks.Open(inputStream); + + IWorkbook workbook =application.Workbooks.Open(assembly.GetManifestResourceStream("Convert_Excel_to_PDF.InputTemplate.xlsx")); - //Initialize XlsIO renderer. - XlsIORenderer renderer = new XlsIORenderer(); + //Initialize XlsIO renderer. + XlsIORenderer renderer = new XlsIORenderer(); - //Convert Excel document into PDF document - PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); + //Convert Excel document into PDF document + PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - //Create the MemoryStream to save the converted PDF. - MemoryStream pdfStream = new MemoryStream(); + //Create the MemoryStream to save the converted PDF. + MemoryStream pdfStream = new MemoryStream(); - //Save the converted PDF document to MemoryStream. - pdfDocument.Save(pdfStream); - pdfStream.Position = 0; + //Save the converted PDF document to MemoryStream. + pdfDocument.Save(pdfStream); + pdfStream.Position = 0; - // Save the PDF file or perform any other action with the PDF - SavePDF(pdfStream); - } + // Save the PDF file or perform any other action with the PDF + SavePDF(pdfStream); } } diff --git a/Getting Started/WPF/Convert Excel to PDF/Convert-Excel-to-PDF/MainWindow.xaml.cs b/Getting Started/WPF/Convert Excel to PDF/Convert-Excel-to-PDF/MainWindow.xaml.cs index e5760b47..648f14d2 100644 --- a/Getting Started/WPF/Convert Excel to PDF/Convert-Excel-to-PDF/MainWindow.xaml.cs +++ b/Getting Started/WPF/Convert Excel to PDF/Convert-Excel-to-PDF/MainWindow.xaml.cs @@ -25,8 +25,7 @@ private void btnConvert_Click(object sender, EventArgs e) application.DefaultVersion = ExcelVersion.Xlsx; //Load an existing file - FileStream excelStream = new FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open("../../Data/InputTemplate.xlsx"); //Initialize ExcelToPdfConverter ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook); @@ -39,10 +38,9 @@ private void btnConvert_Click(object sender, EventArgs e) //Save the converted PDF document pdfDocument.Save("Sample.pdf"); - } //Launch the PDF file System.Diagnostics.Process.Start("Sample.pdf"); } } -} +} \ No newline at end of file diff --git a/Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Form1.cs b/Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Form1.cs index 9c32b582..1466f1e9 100644 --- a/Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Form1.cs +++ b/Getting Started/Windows Forms/Convert Excel to PDF/Convert-Excel-to-PDF/Form1.cs @@ -25,8 +25,7 @@ private void btnConvert_Click(object sender, EventArgs e) application.DefaultVersion = ExcelVersion.Xlsx; //Load an existing file - FileStream excelStream = new FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open("../../Data/InputTemplate.xlsx"); //Initialize ExcelToPdfConverter ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);