Skip to content

Commit 885314c

Browse files
authored
Merge pull request #266 from SyncfusionExamples/991684-GettingStartedSamples
991684-Modify file streams of C# [Cross-platform] in XlsIO UG
2 parents 4a77726 + 4b6458c commit 885314c

File tree

6 files changed

+8
-16
lines changed

6 files changed

+8
-16
lines changed

Getting Started/ASP.NET Core/Edit Excel/Edit Excel/Controllers/HomeController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public IActionResult EditDocument()
3535
application.DefaultVersion = ExcelVersion.Xlsx;
3636

3737
//A existing workbook is opened.
38-
FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
39-
IWorkbook workbook = application.Workbooks.Open(inputStream);
38+
IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx");
4039

4140
//Access first worksheet from the workbook.
4241
IWorksheet worksheet = workbook.Worksheets[0];

Getting Started/AWS/AWS Elastic Beanstalk/EditExcel/EditExcel/Controllers/HomeController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public ActionResult EditExcelDocument()
3333
application.DefaultVersion = ExcelVersion.Xlsx;
3434

3535
//A existing workbook is opened.
36-
FileStream sampleFile = new FileStream("Data/InputTemplate.xlsx", FileMode.Open);
37-
IWorkbook workbook = application.Workbooks.Open(sampleFile);
36+
IWorkbook workbook = application.Workbooks.Open("Data/InputTemplate.xlsx");
3837

3938
//Access first worksheet from the workbook.
4039
IWorksheet worksheet = workbook.Worksheets[0];
@@ -64,4 +63,4 @@ public IActionResult Error()
6463
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
6564
}
6665
}
67-
}
66+
}

Getting Started/AWS/AWS Lambda/Edit Excel/EditExcel/Function.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public string FunctionHandler(string input, ILambdaContext context)
3131
application.DefaultVersion = ExcelVersion.Xlsx;
3232

3333
//A existing workbook is opened.
34-
FileStream sampleFile = new FileStream(@"Data/InputTemplate.xlsx", FileMode.Open);
35-
IWorkbook workbook = application.Workbooks.Open(sampleFile);
34+
IWorkbook workbook = application.Workbooks.Open("Data/InputTemplate.xlsx");
3635

3736
//Access first worksheet from the workbook.
3837
IWorksheet worksheet = workbook.Worksheets[0];

Getting Started/Blazor Web App/Server Side/Edit_Excel/Edit_Excel/Components/Data/ExcelSercive.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public MemoryStream EditExcel()
2020
application.DefaultVersion = ExcelVersion.Xlsx;
2121

2222
//Load the existing Excel workbook into IWorkbook
23-
FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open);
24-
IWorkbook workbook = application.Workbooks.Open(inputStream);
23+
IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx");
2524

2625
//Get the first worksheet in the workbook into IWorksheet
2726
IWorksheet worksheet = workbook.Worksheets[0];

Getting Started/Blazor/Server Side/Edit Excel/Edit Excel/Data/EditExcel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public MemoryStream EditDocument()
2323
application.DefaultVersion = ExcelVersion.Xlsx;
2424

2525
//Load the existing Excel workbook into IWorkbook
26-
FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open);
27-
IWorkbook workbook = application.Workbooks.Open(inputStream);
26+
IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx");
2827

2928
//Get the first worksheet in the workbook into IWorksheet
3029
IWorksheet worksheet = workbook.Worksheets[0];

Getting Started/Console/.NET/Create Excel/Create Excel/Program.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,8 @@ static void Main(string[] args)
179179
worksheet.Range["A9:A14"].RowHeight = 15;
180180
worksheet.Range["A15:A23"].RowHeight = 18;
181181

182-
//Saving the Excel to the Stream
183-
using (FileStream stream = new FileStream(Path.GetFullPath(@"Output/Output.xlsx"), FileMode.Create, FileAccess.Write))
184-
{
185-
workbook.SaveAs(stream);
186-
}
182+
//Saving the Excel
183+
workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx"));
187184
imageStream.Dispose();
188185
}
189186
}

0 commit comments

Comments
 (0)