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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ The following code illustrates adding chart labels to the scatter points of the
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];

//Get the chart from the charts collection
Expand All @@ -30,9 +29,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

//Set the Value to the Data Labels through Data Points
serieOne.DataPoints[0].DataLabels.IsValue = true;

FileStream stream = new FileStream("ChartLabels.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("ChartLabels.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

//To change the grid line color using ExcelKnownColors
worksheet.GridLineColor = ExcelKnownColors.Blue;

FileStream stream = new FileStream("GridLineColor.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("GridLineColor.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
FileStream inputStream1 = new FileStream("SourceWorkbook.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook sourceWorkbook = application.Workbooks.Open(inputStream1, ExcelOpenType.Automatic);
FileStream inputStream2 = new FileStream("DestinationWorkbook.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook destinationWorkbook = application.Workbooks.Open(inputStream2, ExcelOpenType.Automatic);
IWorkbook sourceWorkbook = application.Workbooks.Open("SourceWorkbook.xlsx", ExcelOpenType.Automatic);
IWorkbook destinationWorkbook = application.Workbooks.Open("DestinationWorkbook.xlsx", ExcelOpenType.Automatic);

//The first worksheet object in the worksheets collection in the Source Workbook is accessed.
IWorksheet sourceWorksheet = sourceWorkbook.Worksheets[0];
Expand All @@ -36,8 +34,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Copying (90 rows) from Source to Destination worksheet.
sourceRange.CopyTo(destinationRange);

FileStream stream = new FileStream("CopyingRange.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
destinationWorkbook.SaveAs(stream);
destinationWorkbook.SaveAs("CopyingRange.xlsx");
destinationWorkbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

//Copy and paste the values using ExcelCopyRangeOption
sourceRange.CopyTo(destinationRange, ExcelCopyRangeOptions.None);

FileStream stream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("Output.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
shape.TopRow = 10;
shape.LeftColumn = 3;
shape.RightColumn = 15;

FileStream stream = new FileStream("DiscontinuousRange.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("DiscontinuousRange.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

//Add a sparkline
sparklines.Add(dataRange, referenceRange);

FileStream stream = new FileStream("SparklineFromNamedRange.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("SparklineFromNamedRange.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
rangeCollection.Add(worksheet.Range["D10:D11"]);
rangeCollection.Text = "Welcome";

FileStream stream = new FileStream("DiscontinuousRange.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("DiscontinuousRange.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
blueFont.Italic = true;
blueFont.RGBColor = Color.Blue;
richText.SetFont(4, 7, blueFont);

FileStream stream = new FileStream("FormattingText.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("FormattingText.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ You can hide the summary rows and columns by using the [IsSummaryRowBelow](https
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];

//Hide the summary rows at the bottom
Expand All @@ -25,8 +24,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Hide the summary columns to the right
worksheet.PageSetup.IsSummaryColumnRight = false;

FileStream stream = new FileStream("SuppressRowsColumns.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("SuppressRowsColumns.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ When there exists data that are of different formats, the error marker appears i
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];

//Ignore Error Options
worksheet.Range["B3"].IgnoreErrorOptions = ExcelIgnoreError.All;

FileStream stream = new FileStream("IgnoreGreenError.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("IgnoreGreenError.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ You can import data table with its data type using template markers by setting t
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("TemplateMarker_Formulas.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("TemplateMarker_Formulas.xlsx", ExcelOpenType.Automatic);

//Create Template Marker Processor
ITemplateMarkersProcessor marker = workbook.CreateTemplateMarkersProcessor();
Expand All @@ -27,8 +26,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Process the markers in the template and fill the values as it is in the DataTable
marker.ApplyMarkers();

FileStream stream = new FileStream("TemplateMarkerFormulas.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("TemplateMarkerFormulas.xlsx");

workbook.Close();
excelEngine.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Enumerates all the workbook files from the data folder and clone and merge it into new workbook
foreach (string file in files)
{
//Loads a template document from data folder
FileStream inputStream = new FileStream(file, FileMode.Open, FileAccess.Read);

//Opens the template workbook from stream
IWorkbook tempWorkbook = application.Workbooks.Open(inputStream);

//Disposes the stream
inputStream.Dispose();
IWorkbook tempWorkbook = application.Workbooks.Open(file);

//Cloning all workbook's worksheets
workbook.Worksheets.AddCopy(tempWorkbook.Worksheets);
Expand All @@ -42,8 +35,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Removing the first empty worksheet
workbook.Worksheets.Remove(0);

FileStream outputStream = new FileStream("MergingFiles.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(outputStream);
workbook.SaveAs("MergingFiles.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand All @@ -64,14 +56,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Enumerates all the workbook files from the data folder and clone and merge it into new workbook
foreach (string file in files)
{
//Loads the all template document from data folder
FileStream inputStream = new FileStream(file, FileMode.Open, FileAccess.Read);

//Opens the template workbook from stream
IWorkbook tempWorkbook = application.Workbooks.Open(inputStream);

//Disposes the stream
inputStream.Dispose();
IWorkbook tempWorkbook = application.Workbooks.Open(file);

//Cloning all workbook's worksheets
workbook.Worksheets.AddCopy(tempWorkbook.Worksheets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ using (ExcelEngine excelEngine = new ExcelEngine())
IApplication application = excelEngine.Excel;

//Open an existing XLTM file
FileStream inputStream = new FileStream("Sample.xltm", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xltm", ExcelOpenType.Automatic);

//Save the file as XLSM
FileStream outputStream = new FileStream("Output.xlsm", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(outputStream);
workbook.SaveAs("Output.xlsm");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Opening a File from a Stream
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
FileStream stream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("Output.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ using (ExcelEngine excelEngine = new ExcelEngine())
IApplication application = excelEngine.Excel;

//Open an existing Excel 2013 file
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);

//Save it as "Excel 97 to 2003" format
FileStream outputStream = new FileStream("Output.xls", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(outputStream);
workbook.SaveAs("Output.xls");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ The following code snippet illustrate this.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];

//Sample data
Expand All @@ -31,8 +30,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
worksheet.Range["A1:A10"].Text = "UnLocked";
worksheet.Protect("syncfusion", ExcelSheetProtection.All);

FileStream stream = new FileStream("ProtectCells.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("ProtectCells.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ XlsIO provides support to save a workbook to a .NET stream. The following code s
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);

//Save the workbook to stream
FileStream fileStream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Save the line break inside the cell
worksheet.Range["A1"].CellStyle.WrapText = true;
worksheet.Range["A1"].Text = String.Format("Hello\nworld");

FileStream stream = new FileStream("LineBreak.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("LineBreak.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())

//Format the header
worksheet.PageSetup.CenterHeader = @"&""Gothic,bold""Center Header Text";

FileStream stream = new FileStream("HeaderFormat.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("HeaderFormat.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ XlsIO allows to designate row header to repeat on all pages of a printed workboo
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];

//Print Rows 1 to 3 on every printed page
worksheet.PageSetup.PrintTitleRows = "$A$1:$IV$3";

FileStream stream = new FileStream("TitleRows.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);

workbook.SaveAs("TitleRows.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down Expand Up @@ -68,15 +66,13 @@ XlsIO allows to designate column header to repeat on all pages of a printed work
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];

//Print Columns 1 to 3 on every printed page
worksheet.PageSetup.PrintTitleColumns = "$A$1:$C$65536";

FileStream stream = new FileStream("TitleColumns.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("TitleColumns.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Pivot Top to Bottom sorting of values in 5th column (E) of the pivot table, (i.e.) 4th data column
rowField.AutoSort(PivotFieldSortType.Ascending, 4);

FileStream stream = new FileStream("TopToBottomSort.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("TopToBottomSort.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ You can unfreeze rows and columns in XlsIO by using the [RemovePanes](https://he
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];

//Freeze the panes
Expand All @@ -25,8 +24,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
//Unfreeze the panes
worksheet.RemovePanes();

FileStream stream = new FileStream("Unfreeze.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("Unfreeze.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
MessageBox.Show(name.Name.ToString());
}

FileStream stream = new FileStream("NamedRange.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
workbook.SaveAs(stream);
workbook.SaveAs("NamedRange.xlsx");
workbook.Close();
excelEngine.Dispose();
}
Expand Down