From 3c9ca0cb88aadf45c4ef164e3fa9d38c14bea935 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Wed, 20 Mar 2024 15:26:09 +0530 Subject: [PATCH 01/14] 869954-TemplateMarkers-Notes --- File-Formats/XlsIO/Working-with-Template-Markers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/File-Formats/XlsIO/Working-with-Template-Markers.md b/File-Formats/XlsIO/Working-with-Template-Markers.md index f1ed67b34..c28bd1d02 100644 --- a/File-Formats/XlsIO/Working-with-Template-Markers.md +++ b/File-Formats/XlsIO/Working-with-Template-Markers.md @@ -73,6 +73,8 @@ Syntax: %<MarkerVariable>.<Property>collapsegroup Syntax: %<MarkerVariable>.<Property>expandgroup +N> XlsIO supports only one marker for each cell in the worksheet. + ## Bind from Array An array of data can be binded to the marker in the template document. From cf137f3a97ac0ebbff2797a10ed883937e951d47 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Sat, 13 Apr 2024 10:32:01 +0530 Subject: [PATCH 02/14] 869952-ExportData-Notes --- File-Formats/XlsIO/Working-with-Data.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/File-Formats/XlsIO/Working-with-Data.md b/File-Formats/XlsIO/Working-with-Data.md index 70f7e3422..fbf912f4b 100644 --- a/File-Formats/XlsIO/Working-with-Data.md +++ b/File-Formats/XlsIO/Working-with-Data.md @@ -2244,7 +2244,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); @@ -2264,7 +2264,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 @@ -2283,7 +2283,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 From 7b53c354dc89f8d24b15ba0a69d5ea2972f2cb93 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Sat, 13 Apr 2024 11:00:47 +0530 Subject: [PATCH 03/14] 869952-ExportData-Notes --- File-Formats/XlsIO/Working-with-Data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/XlsIO/Working-with-Data.md b/File-Formats/XlsIO/Working-with-Data.md index fbf912f4b..abff0805d 100644 --- a/File-Formats/XlsIO/Working-with-Data.md +++ b/File-Formats/XlsIO/Working-with-Data.md @@ -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 --- From 0b8fb538b621f95a8dfea7cecec9a83054a2d971 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Sat, 13 Apr 2024 11:29:01 +0530 Subject: [PATCH 04/14] 871981-ImportData-Notes --- File-Formats/XlsIO/Working-with-Data.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/File-Formats/XlsIO/Working-with-Data.md b/File-Formats/XlsIO/Working-with-Data.md index 70f7e3422..199153fbf 100644 --- a/File-Formats/XlsIO/Working-with-Data.md +++ b/File-Formats/XlsIO/Working-with-Data.md @@ -24,6 +24,8 @@ The following code snippet illustrates on how to import a DataTable into a works N> XlsIO supports importing of data from data table to worksheet in Windows Forms, WPF, ASP.NET, ASP.NET MVC and ASP.NET Core (2.0 onwards) platforms alone. +N> When the data table column contains numbers and date values formatted as text, they will be imported as string type only. The number formatting applied to the data table column values will not be effective. To address this, the data table column values should be preserved with their respective data type. + {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} using (ExcelEngine excelEngine = new ExcelEngine()) From 0fcbc7fd62c1a1f0ea3a338fe9cef5a51c8d09c8 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Sat, 13 Apr 2024 13:31:05 +0530 Subject: [PATCH 05/14] 871981-ImportData-Notes --- File-Formats/XlsIO/Working-with-Data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/XlsIO/Working-with-Data.md b/File-Formats/XlsIO/Working-with-Data.md index 199153fbf..5525ed19b 100644 --- a/File-Formats/XlsIO/Working-with-Data.md +++ b/File-Formats/XlsIO/Working-with-Data.md @@ -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 --- From 0541c6a62553f132b88cb3ffa251737ef3d2fef3 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Sat, 13 Apr 2024 22:35:21 +0530 Subject: [PATCH 06/14] 881697-DeleteRows-Performance --- File-Formats-toc.html | 1 + File-Formats/XlsIO/FAQ.md | 5 +- ...ue-when-deleting-a-large-number-of-rows.md | 120 ++++++++++++++++++ 3 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md diff --git a/File-Formats-toc.html b/File-Formats-toc.html index 55b20b781..157a541a1 100644 --- a/File-Formats-toc.html +++ b/File-Formats-toc.html @@ -1687,6 +1687,7 @@
  • How to find and replace text in hyperlinks
  • How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?
  • How to set Logarithmic axis for chart in Excel document?
  • +
  • How to resolve the performance issue when deleting a large number of rows?
  • diff --git a/File-Formats/XlsIO/FAQ.md b/File-Formats/XlsIO/FAQ.md index 87104604d..1ba2bbd86 100644 --- a/File-Formats/XlsIO/FAQ.md +++ b/File-Formats/XlsIO/FAQ.md @@ -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) \ No newline at end of file +* [How to set Logarithmic axis for chart in Excel document?](faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document) +* [How to resolve the performance issue when deleting a large number of rows?](faqs\how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows) \ No newline at end of file diff --git a/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md b/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md new file mode 100644 index 000000000..c628e36e3 --- /dev/null +++ b/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md @@ -0,0 +1,120 @@ +--- +title: How to resolve the performance issue when deleting a large number of rows | Syncfusion +description: This page explains how to resolve the 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 the 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 %} \ No newline at end of file From f029171c1ed34683857ea5ed415cd0a6c0fa91b7 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Sun, 14 Apr 2024 18:36:55 +0530 Subject: [PATCH 07/14] 881697-DeleteRows-Performance --- ...he-performance-issue-when-deleting-a-large-number-of-rows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md b/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md index c628e36e3..e02c3c856 100644 --- a/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md +++ b/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md @@ -1,5 +1,5 @@ --- -title: How to resolve the performance issue when deleting a large number of rows | Syncfusion +title: Resolve the performance issue when deleting a large number of rows | Syncfusion description: This page explains how to resolve the performance issue when deleting a large number of rows using Syncfusion .NET Excel library (XlsIO). platform: file-formats control: XlsIO From f1bd701078d816f6ee19284276226d2347518c16 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Mon, 15 Apr 2024 11:37:03 +0530 Subject: [PATCH 08/14] 881697-DeleteRows-Performance --- File-Formats-toc.html | 2 +- File-Formats/XlsIO/FAQ.md | 2 +- ...ue-when-deleting-a-large-number-of-rows.md | 120 ++++++++++++++++++ 3 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md diff --git a/File-Formats-toc.html b/File-Formats-toc.html index 157a541a1..f5548652e 100644 --- a/File-Formats-toc.html +++ b/File-Formats-toc.html @@ -1687,7 +1687,7 @@
  • How to find and replace text in hyperlinks
  • How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?
  • How to set Logarithmic axis for chart in Excel document?
  • -
  • How to resolve the performance issue when deleting a large number of rows?
  • +
  • How to resolve performance issue when deleting a large number of rows?
  • diff --git a/File-Formats/XlsIO/FAQ.md b/File-Formats/XlsIO/FAQ.md index 1ba2bbd86..faa8cfcbd 100644 --- a/File-Formats/XlsIO/FAQ.md +++ b/File-Formats/XlsIO/FAQ.md @@ -82,4 +82,4 @@ The frequently asked questions in Essential XlsIO are listed below. * [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 resolve the performance issue when deleting a large number of rows?](faqs\how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows) \ No newline at end of file +* [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) \ No newline at end of file diff --git a/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md b/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md new file mode 100644 index 000000000..53bf724fe --- /dev/null +++ b/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md @@ -0,0 +1,120 @@ +--- +title: Resolve performance issue when deleting a large number of rows | 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 %} \ No newline at end of file From 461cab36cb65dbed36739ac4b5e3bdf8f7b23a07 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Mon, 15 Apr 2024 11:42:10 +0530 Subject: [PATCH 09/14] 881697-DeleteRows-Performance --- File-Formats/XlsIO/FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/XlsIO/FAQ.md b/File-Formats/XlsIO/FAQ.md index faa8cfcbd..fb3c5eb10 100644 --- a/File-Formats/XlsIO/FAQ.md +++ b/File-Formats/XlsIO/FAQ.md @@ -82,4 +82,4 @@ The frequently asked questions in Essential XlsIO are listed below. * [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 resolve performance issue when deleting a large number of rows?](faqs\how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows) \ No newline at end of file +* [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) \ No newline at end of file From 095db3d05ec78684dfa5e56042e8d952b51a4c64 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Mon, 15 Apr 2024 11:42:28 +0530 Subject: [PATCH 10/14] 881697-DeleteRows-Performance --- ...ue-when-deleting-a-large-number-of-rows.md | 120 ------------------ 1 file changed, 120 deletions(-) delete mode 100644 File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md diff --git a/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md b/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md deleted file mode 100644 index e02c3c856..000000000 --- a/File-Formats/XlsIO/faqs/how-to-resolve-the-performance-issue-when-deleting-a-large-number-of-rows.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -title: Resolve the performance issue when deleting a large number of rows | Syncfusion -description: This page explains how to resolve the 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 the 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 %} \ No newline at end of file From 4118e7c09dd654aa5db729f2111ae4b3d88f0622 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Mon, 15 Apr 2024 11:49:59 +0530 Subject: [PATCH 11/14] 881697-DeleteRows-Performance --- ...ve-performance-issue-when-deleting-a-large-number-of-rows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md b/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md index 53bf724fe..92c487246 100644 --- a/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md +++ b/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md @@ -1,5 +1,5 @@ --- -title: Resolve performance issue when deleting a large number of rows | Syncfusion +title: Fix performance issue when deleting a large number of rows | 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 From fd9b8eac78db8a82d39ddc95e71cda88e4cc4f48 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Mon, 15 Apr 2024 11:58:52 +0530 Subject: [PATCH 12/14] 881697-DeleteRows-Performance --- ...ve-performance-issue-when-deleting-a-large-number-of-rows.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md b/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md index 92c487246..f4bfbc461 100644 --- a/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md +++ b/File-Formats/XlsIO/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md @@ -1,5 +1,5 @@ --- -title: Fix performance issue when deleting a large number of rows | Syncfusion. +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 From 4bd94f7de9374bbba902d40863a8af020d43ad4b Mon Sep 17 00:00:00 2001 From: MOHAN CHANDRAN <93247949+Mohan2401@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:13:02 +0530 Subject: [PATCH 13/14] Update Working-with-Template-Markers.md --- File-Formats/XlsIO/Working-with-Template-Markers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File-Formats/XlsIO/Working-with-Template-Markers.md b/File-Formats/XlsIO/Working-with-Template-Markers.md index c28bd1d02..380f74708 100644 --- a/File-Formats/XlsIO/Working-with-Template-Markers.md +++ b/File-Formats/XlsIO/Working-with-Template-Markers.md @@ -73,7 +73,7 @@ Syntax: %<MarkerVariable>.<Property>collapsegroup Syntax: %<MarkerVariable>.<Property>expandgroup -N> XlsIO supports only one marker for each cell in the worksheet. +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 From c309d5dd5e076438acb76b1deda2114549bebf56 Mon Sep 17 00:00:00 2001 From: MOHAN CHANDRAN <93247949+Mohan2401@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:18:36 +0530 Subject: [PATCH 14/14] Update Working-with-Data.md --- File-Formats/XlsIO/Working-with-Data.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/File-Formats/XlsIO/Working-with-Data.md b/File-Formats/XlsIO/Working-with-Data.md index 5525ed19b..c7c16d57d 100644 --- a/File-Formats/XlsIO/Working-with-Data.md +++ b/File-Formats/XlsIO/Working-with-Data.md @@ -24,8 +24,6 @@ The following code snippet illustrates on how to import a DataTable into a works N> XlsIO supports importing of data from data table to worksheet in Windows Forms, WPF, ASP.NET, ASP.NET MVC and ASP.NET Core (2.0 onwards) platforms alone. -N> When the data table column contains numbers and date values formatted as text, they will be imported as string type only. The number formatting applied to the data table column values will not be effective. To address this, the data table column values should be preserved with their respective data type. - {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} using (ExcelEngine excelEngine = new ExcelEngine()) @@ -83,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.