Skip to content
Open
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,12 +35,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

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

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

Expand Down Expand Up @@ -95,8 +91,7 @@ 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"));

#region Access
//Accessing via index
Expand All @@ -105,9 +100,6 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Accessing via sheet name
IWorksheet NamedSheet = workbook.Worksheets["Sample"];
#endregion

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

Expand Down Expand Up @@ -173,8 +165,7 @@ 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"));

#region Remove
//Removing the sheet
Expand All @@ -183,13 +174,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

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

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

Expand Down Expand Up @@ -239,12 +225,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Set sheet name
worksheet.Name = "Sample";

//Saving the workbook as stream
FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(stream);

//Dispose streams
stream.Dispose();
//Saving the workbook
workbook.SaveAs("Output.xlsx");
}
{% endhighlight %}

Expand Down Expand Up @@ -304,12 +286,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

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

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

Expand Down Expand Up @@ -395,12 +373,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Auto fill using the series option
source.AutoFill(destinationRange, ExcelAutoFillType.FillSeries);

//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
//Saving the workbook
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
range.FillSeries(ExcelSeriesBy.Columns, ExcelFillSeries.Years, 2, new DateTime(2100, 1, 1));

//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

Expand Down Expand Up @@ -244,11 +240,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
range.FillSeries(ExcelSeriesBy.Columns, ExcelFillSeries.Linear, 5, 1000);

//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

Expand Down Expand Up @@ -327,11 +319,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
range.FillSeries(ExcelSeriesBy.Columns, ExcelFillSeries.Linear, true);

//Saving the workbook
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ 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];

//Applying freeze rows to the sheet by specifying a cell
Expand All @@ -36,13 +35,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Set first visible row in the bottom pane
worksheet.FirstVisibleRow = 3;

//Saving the workbook as stream
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
inputStream.Dispose();
//Saving the workbook
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

Expand Down Expand Up @@ -96,8 +90,7 @@ 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];

//Applying freeze columns to the sheet by specifying a cell
Expand All @@ -106,13 +99,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Set first visible column in the right pane
worksheet.FirstVisibleColumn = 4;

//Saving the workbook as stream
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
inputStream.Dispose();
//Saving the workbook
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

Expand Down Expand Up @@ -168,20 +156,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];

//Unfreeze panes in the worksheet
worksheet.RemovePanes();

//Saving the workbook as stream
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(outputStream);

//Dispose streams
outputStream.Dispose();
inputStream.Dispose();
//Saving the workbook
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

Expand Down Expand Up @@ -246,12 +228,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

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

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

Expand Down
Loading