Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Syncfusion.XlsIO;
using Syncfusion.XlsIO;
using System;
using System.IO;

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

#region save as JSON
//Saves the workbook to a JSON filestream, as schema by default
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema-default.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(outputStream);

//Saves the workbook to a JSON filestream as schema
FileStream stream1 = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(stream1, true);
#endregion
FileStream jsonWithSchema = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(jsonWithSchema, true);

//Dispose streams
outputStream.Dispose();
stream1.Dispose();
jsonWithSchema.Dispose();
inputStream.Dispose();

#region Open JSON
//Open default JSON

//Open JSON with Schema
#endregion
}
}
}
}





Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,20 @@ Step 5: Include the below code snippet in **Program.cs** to convert an Excel wor
```csharp
using (ExcelEngine excelEngine = new ExcelEngine())
{
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);
IWorksheet worksheet = workbook.Worksheets[0];

#region save as JSON
//Saves the workbook to a JSON filestream, as schema by default
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Excel-Workbook-To-JSON-as-schema-default.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(outputStream);

//Saves the workbook to a JSON filestream as schema
FileStream stream1 = new FileStream(Path.GetFullPath(@"Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(stream1, true);
#endregion

//Dispose streams
outputStream.Dispose();
stream1.Dispose();
inputStream.Dispose();

#region Open JSON
//Open default JSON

//Open JSON with Schema
#endregion
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);
IWorksheet worksheet = workbook.Worksheets[0];

//Saves the workbook to a JSON filestream as schema
FileStream jsonWithSchema = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(jsonWithSchema, true);

//Dispose streams
jsonWithSchema.Dispose();
inputStream.Dispose();
}
```

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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static void Main(string[] args)
{
workbook.SaveAs(stream);
}
imageStream.Dispose();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ using (ExcelEngine excelEngine = new ExcelEngine())
worksheet.Range["A15:A23"].RowHeight = 18;

//Saving the Excel to the Stream
FileStream stream = new FileStream(Path.GetFullPath(@"Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(stream);
using (FileStream stream = new FileStream(Path.GetFullPath(@"Output/Output.xlsx"), FileMode.Create, FileAccess.Write))
{
workbook.SaveAs(stream);
}
imageStream.Dispose();
}
```

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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static void Main(string[] args)

//Dispose streams
outputStream.Dispose();
inputStream.Dispose();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

//Dispose streams
outputStream.Dispose();
inputStream.Dispose();
}
```

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.
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.
Loading