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 @@ -12,28 +12,20 @@ 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];

//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
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@ 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];

//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
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ 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];

//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();
//Saves the workbook to JSON as schema
workbook.SaveAsJson(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ 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];

#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
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@ 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];

#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
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ 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];

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

#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();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ static void Main(string[] args)

#region Save
//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/ExcelToODS.ods"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream, ExcelSaveType.SaveAsODS);
workbook.SaveAs("Output.ods");
#endregion

//Dispose streams
outputStream.Dispose();
}
}
}
Expand Down