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
Expand Up @@ -35,7 +35,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
worksheet.SaveAsHtml(stream);

//Save a workbook as HTML file
workbook.SaveAsHtml(stream, Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default);
workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default);
stream.Dispose();
workbook.Close();
}
Expand Down Expand Up @@ -97,12 +97,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

#region Save as HTML
//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.html"), FileMode.Create, FileAccess.Write);
workbook.SaveAsHtml(outputStream, saveOptions);
workbook.SaveAsHtml(Path.GetFullPath("Output/Output.html"), saveOptions);
#endregion

//Dispose streams
outputStream.Dispose();
}
{% endhighlight %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
worksheet.SaveAsHtml(stream);

//Save a workbook as HTML file
workbook.SaveAsHtml(stream, Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default);
workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default);
stream.Dispose();
workbook.Close();
}
Expand Down Expand Up @@ -97,12 +97,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

#region Save as HTML
//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.html"), FileMode.Create, FileAccess.Write);
workbook.SaveAsHtml(outputStream, saveOptions);
workbook.SaveAsHtml(Path.GetFullPath("Output/Output.html"), saveOptions);
#endregion

//Dispose streams
outputStream.Dispose();
}
{% endhighlight %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,17 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
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 JSON, as schema by default
workbook.SaveAsJson(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema-default.json"));

//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);
//Saves the workbook to JSON as schema
workbook.SaveAsJson("Output/Excel-Workbook-To-JSON-as-schema.json", true);
#endregion

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

#region Open JSON
//Open default JSON

Expand Down Expand Up @@ -181,20 +173,14 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

#region save as JSON
//Saves the workbook to a JSON file without schema
FileStream outputStream = new FileStream("Output/Workbook-To-JSON-without-schema.json", FileMode.Create);
workbook.SaveAsJson(outputStream,false);
//Saves the workbook to JSON file without schema
workbook.SaveAsJson(Path.GetFullPath(@"Output/Workbook-To-JSON-without-schema.json"),false);
#endregion

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

#region Open JSON
//Open default JSON
#endregion
Expand Down Expand Up @@ -311,25 +297,17 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

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

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

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

#region Open JSON
//Open default JSON

Expand Down Expand Up @@ -466,20 +444,14 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
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-Worksheet-To-JSON-filestream-without-schema.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(outputStream, worksheet,false);
//Saves the workbook to JSON, as schema by default
workbook.SaveAsJson(Path.GetFullPath("Output/Excel-Worksheet-To-JSON-filestream-without-schema.json"), worksheet,false);
#endregion

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

#region Open JSON
//Open default JSON
#endregion
Expand Down Expand Up @@ -602,28 +574,20 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

//Custom range
IRange range = worksheet.Range["A1:F100"];

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

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

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

#region Open JSON
//Open default JSON

Expand Down Expand Up @@ -769,23 +733,17 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

//Custom range
IRange range = worksheet.Range["A1:F100"];

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

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

#region Open JSON
//Open default JSON
#endregion
Expand Down
90 changes: 24 additions & 66 deletions Document-Processing/Excel/Conversions/Excel-to-JSON/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,17 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
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 JSON, as schema by default
workbook.SaveAsJson(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema-default.json"));

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

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

#region Open JSON
//Open default JSON

Expand Down Expand Up @@ -181,20 +173,14 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

#region save as JSON
//Saves the workbook to a JSON file without schema
FileStream outputStream = new FileStream("Output/Workbook-To-JSON-without-schema.json", FileMode.Create);
workbook.SaveAsJson(outputStream,false);
//Saves the workbook to JSON file without schema
workbook.SaveAsJson(Path.GetFullPath(@"Output/Workbook-To-JSON-without-schema.json"),false);
#endregion

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

#region Open JSON
//Open default JSON
#endregion
Expand Down Expand Up @@ -311,25 +297,17 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

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

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

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

#region Open JSON
//Open default JSON

Expand Down Expand Up @@ -466,20 +444,14 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
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-Worksheet-To-JSON-filestream-without-schema.json"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAsJson(outputStream, worksheet,false);
//Saves the workbook to JSON, as schema by default
workbook.SaveAsJson(Path.GetFullPath("Output/Excel-Worksheet-To-JSON-filestream-without-schema.json"), worksheet,false);
#endregion

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

#region Open JSON
//Open default JSON
#endregion
Expand Down Expand Up @@ -602,28 +574,20 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

//Custom range
IRange range = worksheet.Range["A1:F100"];

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

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

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

#region Open JSON
//Open default JSON

Expand Down Expand Up @@ -769,23 +733,17 @@ 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);
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];

//Custom range
IRange range = worksheet.Range["A1:F100"];

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

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

#region Open JSON
//Open default JSON
#endregion
Expand Down
Loading