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
1 change: 1 addition & 0 deletions File-Formats-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,7 @@
<li><a href="/file-formats/xlsio/faqs/how-to-find-and-replace-text-in-hyperlinks">How to find and replace text in hyperlinks</a></li>
<li><a href="/file-formats/xlsio/faqs/how-to-fix-the-argument-out-of-range-exception-when-accessing-a-large-number-of-rows-and-columns">How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?</a></li>
<li><a href="/file-formats/xlsio/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document">How to set Logarithmic axis for chart in Excel document?</a></li>
<li><a href="/file-formats/xlsio/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows">How to resolve performance issue when deleting a large number of rows?</a></li>
</ul>
</li>
</ul>
Expand Down
5 changes: 3 additions & 2 deletions File-Formats/XlsIO/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The frequently asked questions in Essential XlsIO are listed below.
* [Why cone chart shows itself as column or bar chart?](faqs/why-cone-chart-shows-itself-as-colum-or-bar-chart)
* [How to vary colors by point for line and column chart?](faqs/how-to-vary-colors-by-point-for-line-and-column-chart)
* [How to upload a file to Azure blob and download as stream?](faqs/how-to-upload-a-file-to-azure-blob-and-download-as-stream)
* [How to find and replace text in hyperlinks](faqs/how-to-find-and-replace-text-in-hyperlinks)
* [How to find and replace text in hyperlinks?](faqs/how-to-find-and-replace-text-in-hyperlinks)
* [How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?](faqs/how-to-fix-the-argument-out-of-range-exception-when-accessing-a-large-number-of-rows-and-columns)
* [How to set Logarithmic axis for chart in Excel document](faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document)
* [How to set Logarithmic axis for chart in Excel document?](faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document)
* [How to resolve performance issue when deleting a large number of rows?](faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows)
10 changes: 6 additions & 4 deletions File-Formats/XlsIO/Working-with-Data.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Working with Data | Syncfusion
description: Learn how to import data to Excel file from ADO.NET objects, Collections, Array; and how to export data from Excel to ADO.NET objects or collections.
platform: file-Formats
platform: file-formats
control: XlsIO
documentation: UG
---
Expand Down Expand Up @@ -81,6 +81,8 @@ End Using

A complete working example to import data from DataTable to Excel worksheet in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Import%20and%20Export%20Data/DataTable%20to%20Worksheet).

N> XlsIO imports the data from data table into Excel worksheet based on the data table column type. So, it is suggested to create the data tables with required column types such as number, text or date time before importing the data table to Excel worksheet.

### Import Data from DataColumn

The following code snippet illustrates how to import DataColumn into a worksheet using [ImportDataColumn](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_ImportDataColumn_System_Data_DataColumn_System_Boolean_System_Int32_System_Int32_) method.
Expand Down Expand Up @@ -2244,7 +2246,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
IWorksheet worksheet = workbook.Worksheets[0];

//Read data from the worksheet and Export to the DataTable
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames);
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.ComputedFormulaValues);

//Saving the workbook as stream
FileStream stream = new FileStream("ExportToDT.xlsx", FileMode.Create, FileAccess.ReadWrite);
Expand All @@ -2264,7 +2266,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
IWorksheet worksheet = workbook.Worksheets[0];

//Read data from the worksheet and Export to the DataTable
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames);
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.ComputedFormulaValues);

//Binding exported DataTable to data grid, likewise it can binded to any
//user interface control which supports binding
Expand All @@ -2283,7 +2285,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine()
Dim sheet As IWorksheet = workbook.Worksheets(0)

'Read data from the worksheet and Export to the DataTable
Dim customersTable As DataTable = sheet.ExportDataTable(sheet.UsedRange, ExcelExportDataTableOptions.ColumnNames)
Dim customersTable As DataTable = sheet.ExportDataTable(sheet.UsedRange, ExcelExportDataTableOptions.ColumnNames Or ExcelExportDataTableOptions.ComputedFormulaValues)

'Binding exported DataTable to data grid, likewise it can binded to any
'user interface control which supports binding
Expand Down
2 changes: 2 additions & 0 deletions File-Formats/XlsIO/Working-with-Template-Markers.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Syntax: %&lt;MarkerVariable&gt;.&lt;Property&gt;collapsegroup

Syntax: %&lt;MarkerVariable&gt;.&lt;Property&gt;expandgroup

N> XlsIO supports only one marker for each cell while importing data from data sources to Excel templates. This is the behavior of template marker in XlsIO.

## Bind from Array

An array of data can be binded to the marker in the template document.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
title: Resolve performance issue while deleting |Syncfusion.
description: This page explains how to resolve performance issue when deleting a large number of rows using Syncfusion .NET Excel library (XlsIO).
platform: file-formats
control: XlsIO
documentation: UG
---

# How to resolve performance issue when deleting a large number of rows?

To address the performance issue, rather than deleting the large number of blank rows using the DeleteRow method, copy the row containing values to a new worksheet and then delete the previous worksheet.

The following code illustrates how to resolve performance issue when deleting a large number of rows.

{% tabs %}
{% highlight c# tabtitle="C# [Cross-platform]" %}
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

//Loads an existing file
FileStream fileStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(fileStream);
IWorksheet worksheet = workbook.Worksheets[0];
IWorksheet newWorksheet = workbook.Worksheets[1];

IRange usedRange = worksheet.UsedRange;
int rowIndexSheet1 = 1;
int rowIndexSheet2 = 1;
foreach (IRange row in usedRange.Rows)
{
RowStorage rowStorage = WorksheetHelper.GetOrCreateRow(worksheet as IInternalWorksheet, rowIndexSheet1 - 1, false);
if (rowStorage != null)
{
// Copy the Entire row to the next sheet
IRange destinationRow = newWorksheet.Range[rowIndexSheet2, 1];
row.EntireRow.CopyTo(destinationRow);
rowIndexSheet2++;
}
rowIndexSheet1++;
}

//Remove the worksheet
workbook.Worksheets[0].Remove();

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

{% highlight c# tabtitle="C# [Windows-specific]" %}
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

//Loads an existing file
IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
IWorksheet newWorksheet = workbook.Worksheets[1];

IRange usedRange = worksheet.UsedRange;
int rowIndexSheet1 = 1;
int rowIndexSheet2 = 1;
foreach (IRange row in usedRange.Rows)
{
RowStorage rowStorage = WorksheetHelper.GetOrCreateRow(worksheet as IInternalWorksheet, rowIndexSheet1 - 1, false);
if (rowStorage != null)
{
// Copy the Entire row to the next sheet
IRange destinationRow = newWorksheet.Range[rowIndexSheet2, 1];
row.EntireRow.CopyTo(destinationRow);
rowIndexSheet2++;
}
rowIndexSheet1++;
}

//Remove the worksheet
workbook.Worksheets[0].Remove();

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

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
Using excelEngine As New ExcelEngine()
Dim application As IApplication = excelEngine.Excel
application.DefaultVersion = ExcelVersion.Xlsx

' Loads an existing file
Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx")
Dim worksheet As IWorksheet = workbook.Worksheets(0)
Dim newWorksheet As IWorksheet = workbook.Worksheets(1)

Dim usedRange As IRange = worksheet.UsedRange
Dim rowIndexSheet1 As Integer = 1
Dim rowIndexSheet2 As Integer = 1
For Each row As IRange In usedRange.Rows
Dim rowStorage As RowStorage = WorksheetHelper.GetOrCreateRow(TryCast(worksheet, IInternalWorksheet), rowIndexSheet1 - 1, False)
If rowStorage IsNot Nothing Then
' Copy the Entire row to the next sheet
Dim destinationRow As IRange = newWorksheet.Range(rowIndexSheet2, 1)
row.EntireRow.CopyTo(destinationRow)
rowIndexSheet2 += 1
End If
rowIndexSheet1 += 1
Next

' Remove the worksheet
workbook.Worksheets(0).Remove()

' Saving the workbook
workbook.SaveAs("Output.xlsx")
End Using
{% endhighlight %}
{% endtabs %}