Skip to content

Commit 807a5b5

Browse files
authored
Merge pull request #160 from SyncfusionExamples/Playground-Changes
Playground changes
2 parents fa995f4 + 66afd66 commit 807a5b5

File tree

6 files changed

+28
-53
lines changed

6 files changed

+28
-53
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Syncfusion.XlsIO;
1+
using Syncfusion.XlsIO;
22
using System;
33
using System.IO;
44

@@ -16,32 +16,14 @@ static void Main(string[] args)
1616
IWorkbook workbook = application.Workbooks.Open(inputStream);
1717
IWorksheet worksheet = workbook.Worksheets[0];
1818

19-
#region save as JSON
20-
//Saves the workbook to a JSON filestream, as schema by default
21-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema-default.json"), FileMode.Create, FileAccess.ReadWrite);
22-
workbook.SaveAsJson(outputStream);
23-
2419
//Saves the workbook to a JSON filestream as schema
25-
FileStream stream1 = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
26-
workbook.SaveAsJson(stream1, true);
27-
#endregion
20+
FileStream jsonWithSchema = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
21+
workbook.SaveAsJson(jsonWithSchema, true);
2822

2923
//Dispose streams
30-
outputStream.Dispose();
31-
stream1.Dispose();
24+
jsonWithSchema.Dispose();
3225
inputStream.Dispose();
33-
34-
#region Open JSON
35-
//Open default JSON
36-
37-
//Open JSON with Schema
38-
#endregion
3926
}
4027
}
4128
}
4229
}
43-
44-
45-
46-
47-

Convert Excel to JSON/Workbook to JSON with Schema/.NET/Workbook to JSON with Schema/Workbook to JSON with Schema/README.md

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,20 @@ Step 5: Include the below code snippet in **Program.cs** to convert an Excel wor
2121
```csharp
2222
using (ExcelEngine excelEngine = new ExcelEngine())
2323
{
24-
IApplication application = excelEngine.Excel;
25-
application.DefaultVersion = ExcelVersion.Xlsx;
26-
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
27-
IWorkbook workbook = application.Workbooks.Open(inputStream);
28-
IWorksheet worksheet = workbook.Worksheets[0];
29-
30-
#region save as JSON
31-
//Saves the workbook to a JSON filestream, as schema by default
32-
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Excel-Workbook-To-JSON-as-schema-default.json"), FileMode.Create, FileAccess.ReadWrite);
33-
workbook.SaveAsJson(outputStream);
34-
35-
//Saves the workbook to a JSON filestream as schema
36-
FileStream stream1 = new FileStream(Path.GetFullPath(@"Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
37-
workbook.SaveAsJson(stream1, true);
38-
#endregion
39-
40-
//Dispose streams
41-
outputStream.Dispose();
42-
stream1.Dispose();
43-
inputStream.Dispose();
44-
45-
#region Open JSON
46-
//Open default JSON
47-
48-
//Open JSON with Schema
49-
#endregion
24+
IApplication application = excelEngine.Excel;
25+
application.DefaultVersion = ExcelVersion.Xlsx;
26+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
27+
IWorkbook workbook = application.Workbooks.Open(inputStream);
28+
IWorksheet worksheet = workbook.Worksheets[0];
29+
30+
//Saves the workbook to a JSON filestream as schema
31+
FileStream jsonWithSchema = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
32+
workbook.SaveAsJson(jsonWithSchema, true);
33+
34+
//Dispose streams
35+
jsonWithSchema.Dispose();
36+
inputStream.Dispose();
5037
}
5138
```
5239

53-
More information about converting an Excel workbook to a JSON file with schema can be found in this [documentation](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-json/overview#workbook-to-json-as-schema) section.
40+
More information about converting an Excel workbook to a JSON file with schema can be found in this [documentation](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-json/overview#workbook-to-json-as-schema) section.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static void Main(string[] args)
184184
{
185185
workbook.SaveAs(stream);
186186
}
187+
imageStream.Dispose();
187188
}
188189
}
189190
}

Getting Started/Console/.NET/Create Excel/Create Excel/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,12 @@ using (ExcelEngine excelEngine = new ExcelEngine())
193193
worksheet.Range["A15:A23"].RowHeight = 18;
194194

195195
//Saving the Excel to the Stream
196-
FileStream stream = new FileStream(Path.GetFullPath(@"Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
197-
workbook.SaveAs(stream);
196+
using (FileStream stream = new FileStream(Path.GetFullPath(@"Output/Output.xlsx"), FileMode.Create, FileAccess.Write))
197+
{
198+
workbook.SaveAs(stream);
199+
}
200+
imageStream.Dispose();
198201
}
199202
```
200203

201-
More information about creating an Excel document can be found in this [documentation](https://help.syncfusion.com/document-processing/excel/excel-library/net/create-excel-files-in-console-apps-c-sharp) section.
204+
More information about creating an Excel document can be found in this [documentation](https://help.syncfusion.com/document-processing/excel/excel-library/net/create-excel-files-in-console-apps-c-sharp) section.

Threaded Comments/Add Comment/.NET/Add Comment/Add Comment/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static void Main(string[] args)
2929

3030
//Dispose streams
3131
outputStream.Dispose();
32+
inputStream.Dispose();
3233
}
3334
}
3435
}

Threaded Comments/Add Comment/.NET/Add Comment/Add Comment/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
4040

4141
//Dispose streams
4242
outputStream.Dispose();
43+
inputStream.Dispose();
4344
}
4445
```
4546

46-
More information about adding a threaded comments in the worksheet can be found in this [documentation](https://help.syncfusion.com/document-processing/excel/excel-library/net/working-with-drawing-objects#create) section.
47+
More information about adding a threaded comments in the worksheet can be found in this [documentation](https://help.syncfusion.com/document-processing/excel/excel-library/net/working-with-drawing-objects#create) section.

0 commit comments

Comments
 (0)