Skip to content

Commit 5f36487

Browse files
Merge pull request #2052 from Syncfusion-Content/hotfix/hotfix-v25.1.35
DOCINFRA-2341_merged_using_automation
2 parents ae0e3ed + bef16df commit 5f36487

File tree

5 files changed

+132
-6
lines changed

5 files changed

+132
-6
lines changed

File-Formats-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,7 @@
16871687
<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>
16881688
<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>
16891689
<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>
1690+
<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>
16901691
</ul>
16911692
</li>
16921693
</ul>

File-Formats/XlsIO/FAQ.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ The frequently asked questions in Essential XlsIO are listed below.
7979
* [Why cone chart shows itself as column or bar chart?](faqs/why-cone-chart-shows-itself-as-colum-or-bar-chart)
8080
* [How to vary colors by point for line and column chart?](faqs/how-to-vary-colors-by-point-for-line-and-column-chart)
8181
* [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)
82-
* [How to find and replace text in hyperlinks](faqs/how-to-find-and-replace-text-in-hyperlinks)
82+
* [How to find and replace text in hyperlinks?](faqs/how-to-find-and-replace-text-in-hyperlinks)
8383
* [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)
84-
* [How to set Logarithmic axis for chart in Excel document](faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document)
84+
* [How to set Logarithmic axis for chart in Excel document?](faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document)
85+
* [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)

File-Formats/XlsIO/Working-with-Data.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Working with Data | Syncfusion
33
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.
4-
platform: file-Formats
4+
platform: file-formats
55
control: XlsIO
66
documentation: UG
77
---
@@ -81,6 +81,8 @@ End Using
8181

8282
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).
8383

84+
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.
85+
8486
### Import Data from DataColumn
8587

8688
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.
@@ -2244,7 +2246,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
22442246
IWorksheet worksheet = workbook.Worksheets[0];
22452247

22462248
//Read data from the worksheet and Export to the DataTable
2247-
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames);
2249+
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.ComputedFormulaValues);
22482250

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

22662268
//Read data from the worksheet and Export to the DataTable
2267-
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames);
2269+
DataTable customersTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.ColumnNames | ExcelExportDataTableOptions.ComputedFormulaValues);
22682270

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

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

22882290
'Binding exported DataTable to data grid, likewise it can binded to any
22892291
'user interface control which supports binding

File-Formats/XlsIO/Working-with-Template-Markers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Syntax: %&lt;MarkerVariable&gt;.&lt;Property&gt;collapsegroup
7373

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

76+
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.
77+
7678
## Bind from Array
7779

7880
An array of data can be binded to the marker in the template document.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: Resolve performance issue while deleting |Syncfusion.
3+
description: This page explains how to resolve performance issue when deleting a large number of rows using Syncfusion .NET Excel library (XlsIO).
4+
platform: file-formats
5+
control: XlsIO
6+
documentation: UG
7+
---
8+
9+
# How to resolve performance issue when deleting a large number of rows?
10+
11+
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.
12+
13+
The following code illustrates how to resolve performance issue when deleting a large number of rows.
14+
15+
{% tabs %}
16+
{% highlight c# tabtitle="C# [Cross-platform]" %}
17+
using(ExcelEngine excelEngine = new ExcelEngine())
18+
{
19+
IApplication application = excelEngine.Excel;
20+
application.DefaultVersion = ExcelVersion.Xlsx;
21+
22+
//Loads an existing file
23+
FileStream fileStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
24+
IWorkbook workbook = application.Workbooks.Open(fileStream);
25+
IWorksheet worksheet = workbook.Worksheets[0];
26+
IWorksheet newWorksheet = workbook.Worksheets[1];
27+
28+
IRange usedRange = worksheet.UsedRange;
29+
int rowIndexSheet1 = 1;
30+
int rowIndexSheet2 = 1;
31+
foreach (IRange row in usedRange.Rows)
32+
{
33+
RowStorage rowStorage = WorksheetHelper.GetOrCreateRow(worksheet as IInternalWorksheet, rowIndexSheet1 - 1, false);
34+
if (rowStorage != null)
35+
{
36+
// Copy the Entire row to the next sheet
37+
IRange destinationRow = newWorksheet.Range[rowIndexSheet2, 1];
38+
row.EntireRow.CopyTo(destinationRow);
39+
rowIndexSheet2++;
40+
}
41+
rowIndexSheet1++;
42+
}
43+
44+
//Remove the worksheet
45+
workbook.Worksheets[0].Remove();
46+
47+
//Saving the workbook as stream
48+
FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
49+
workbook.SaveAs(stream);
50+
stream.Dispose();
51+
}
52+
{% endhighlight %}
53+
54+
{% highlight c# tabtitle="C# [Windows-specific]" %}
55+
using(ExcelEngine excelEngine = new ExcelEngine())
56+
{
57+
IApplication application = excelEngine.Excel;
58+
application.DefaultVersion = ExcelVersion.Xlsx;
59+
60+
//Loads an existing file
61+
IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx");
62+
IWorksheet worksheet = workbook.Worksheets[0];
63+
IWorksheet newWorksheet = workbook.Worksheets[1];
64+
65+
IRange usedRange = worksheet.UsedRange;
66+
int rowIndexSheet1 = 1;
67+
int rowIndexSheet2 = 1;
68+
foreach (IRange row in usedRange.Rows)
69+
{
70+
RowStorage rowStorage = WorksheetHelper.GetOrCreateRow(worksheet as IInternalWorksheet, rowIndexSheet1 - 1, false);
71+
if (rowStorage != null)
72+
{
73+
// Copy the Entire row to the next sheet
74+
IRange destinationRow = newWorksheet.Range[rowIndexSheet2, 1];
75+
row.EntireRow.CopyTo(destinationRow);
76+
rowIndexSheet2++;
77+
}
78+
rowIndexSheet1++;
79+
}
80+
81+
//Remove the worksheet
82+
workbook.Worksheets[0].Remove();
83+
84+
//Saving the workbook as stream
85+
workbook.SaveAs("Output.xlsx");
86+
}
87+
{% endhighlight %}
88+
89+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
90+
Using excelEngine As New ExcelEngine()
91+
Dim application As IApplication = excelEngine.Excel
92+
application.DefaultVersion = ExcelVersion.Xlsx
93+
94+
' Loads an existing file
95+
Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx")
96+
Dim worksheet As IWorksheet = workbook.Worksheets(0)
97+
Dim newWorksheet As IWorksheet = workbook.Worksheets(1)
98+
99+
Dim usedRange As IRange = worksheet.UsedRange
100+
Dim rowIndexSheet1 As Integer = 1
101+
Dim rowIndexSheet2 As Integer = 1
102+
For Each row As IRange In usedRange.Rows
103+
Dim rowStorage As RowStorage = WorksheetHelper.GetOrCreateRow(TryCast(worksheet, IInternalWorksheet), rowIndexSheet1 - 1, False)
104+
If rowStorage IsNot Nothing Then
105+
' Copy the Entire row to the next sheet
106+
Dim destinationRow As IRange = newWorksheet.Range(rowIndexSheet2, 1)
107+
row.EntireRow.CopyTo(destinationRow)
108+
rowIndexSheet2 += 1
109+
End If
110+
rowIndexSheet1 += 1
111+
Next
112+
113+
' Remove the worksheet
114+
workbook.Worksheets(0).Remove()
115+
116+
' Saving the workbook
117+
workbook.SaveAs("Output.xlsx")
118+
End Using
119+
{% endhighlight %}
120+
{% endtabs %}

0 commit comments

Comments
 (0)