From 99dd3164feab7eb5f1b13a6bbeec9d5e81362c02 Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Thu, 18 Dec 2025 11:06:13 +0530 Subject: [PATCH 1/2] 989035-How to apply the formatting for a particular column while importing data from collection objects --- ...-importing-data-from-collection-objects.md | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-the-formatting-for-a-particular-column-while-importing-data-from-collection-objects.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-the-formatting-for-a-particular-column-while-importing-data-from-collection-objects.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-the-formatting-for-a-particular-column-while-importing-data-from-collection-objects.md new file mode 100644 index 000000000..14d963da0 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-the-formatting-for-a-particular-column-while-importing-data-from-collection-objects.md @@ -0,0 +1,171 @@ +--- +title: Apply formatting to a specific column when importing data | Syncfusion +description: Code example showing how to apply formatting to a specific column when importing data from collection objects using the Syncfusion .NET Excel library (XlsIO). +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to apply formatting to a specific column while importing data? + +To apply formatting to a specific column while importing data from collection objects, use the **DisplayFormatAttribute** in the class definition, as shown in the example below. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Import the data to worksheet + IList reports = GetSalesReports(); + worksheet.ImportData(reports, 2, 1, false); + + #region Save + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/ImportCollectionObjects.xlsx")); + #endregion +} + +//Gets a list of sales reports +public static List GetSalesReports() +{ + List reports = new List(); + reports.Add(new Customer("Andy Bernard", 45000, 58000)); + reports.Add(new Customer("Jim Halpert", 34000, 65000)); + reports.Add(new Customer("Karen Fillippelli", 75000, 64000)); + reports.Add(new Customer("Phyllis Lapin", 56500, 33600)); + reports.Add(new Customer("Stanley Hudson", 46500, 52000)); + return reports; +} + +//Customer details +public class Customer +{ + [DisplayNameAttribute("Sales Person Name")] + public string SalesPerson + { + get; set; + } + **[DisplayFormat(DataFormatString = "$#,###.00")]** + public int SalesJanJun { get; set; } + + **[DisplayFormat(DataFormatString = "$#,###.00")]** + public int SalesJulDec { get; set; } + + public Customer(string name, int janToJun, int julToDec) + { + SalesPerson = name; + SalesJanJun = janToJun; + SalesJulDec = julToDec; + } +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Import the data to worksheet + IList reports = GetSalesReports(); + worksheet.ImportData(reports, 2, 1, false); + + #region Save + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/ImportCollectionObjects.xlsx")); + #endregion +} + +//Gets a list of sales reports +public static List GetSalesReports() +{ + List reports = new List(); + reports.Add(new Customer("Andy Bernard", 45000, 58000)); + reports.Add(new Customer("Jim Halpert", 34000, 65000)); + reports.Add(new Customer("Karen Fillippelli", 75000, 64000)); + reports.Add(new Customer("Phyllis Lapin", 56500, 33600)); + reports.Add(new Customer("Stanley Hudson", 46500, 52000)); + return reports; +} + +//Customer details +public class Customer +{ + [DisplayNameAttribute("Sales Person Name")] + public string SalesPerson + { + get; set; + } + **[DisplayFormat(DataFormatString = "$#,###.00")]** + public int SalesJanJun { get; set; } + + **[DisplayFormat(DataFormatString = "$#,###.00")]** + public int SalesJulDec { get; set; } + + public Customer(string name, int janToJun, int julToDec) + { + SalesPerson = name; + SalesJanJun = janToJun; + SalesJulDec = julToDec; + } +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + + Dim workbook As IWorkbook = application.Workbooks.Create(1) + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + ' Import the data to worksheet + Dim reports As IList(Of Customer) = GetSalesReports() + worksheet.ImportData(reports, 2, 1, False) + + ' Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/ImportCollectionObjects.xlsx")) +End Using + +' Gets a list of sales reports +Public Function GetSalesReports() As List(Of Customer) + Dim reports As New List(Of Customer)() + reports.Add(New Customer("Andy Bernard", 45000, 58000)) + reports.Add(New Customer("Jim Halpert", 34000, 65000)) + reports.Add(New Customer("Karen Fillippelli", 75000, 64000)) + reports.Add(New Customer("Phyllis Lapin", 56500, 33600)) + reports.Add(New Customer("Stanley Hudson", 46500, 52000)) + Return reports +End Function + +' Customer details +Public Class Customer + + Public Property SalesPerson As String + + **** + Public Property SalesJanJun As Integer + + **** + Public Property SalesJulDec As Integer + + Public Sub New(name As String, janToJun As Integer, julToDec As Integer) + SalesPerson = name + SalesJanJun = janToJun + SalesJulDec = julToDec + End Sub +End Class +{% endhighlight %} +{% endtabs %} + +## See Also + +* [Collection Objects to Excel](https://help.syncfusion.com/document-processing/excel/excel-library/net/import-export/import-to-excel#collection-objects-to-excel) +* [How to import data table with its data type using template markers?](https://help.syncfusion.com/document-processing/excel/excel-library/net/faqs/how-to-import-data-table-with-its-data-type-using-template-markers) +* [Working with Template Markers](https://help.syncfusion.com/document-processing/excel/excel-library/net/working-with-template-markers) \ No newline at end of file From 184939939a38f7e6c290bfd62622f92df199bd16 Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Thu, 18 Dec 2025 11:47:39 +0530 Subject: [PATCH 2/2] November 2nd sprint tasks --- .../Excel/Excel-Library/NET/Slicer.md | 135 ++++++++++++++++++ ...support-converting-an-xlsb-file-to-xlsx.md | 56 ++++++++ .../how-to-align-the-image-inside-the-cell.md | 106 ++++++++++++++ ...files-from-an-Excel-workbook-as-streams.md | 43 ++++++ ...nnot-open-Pivot-table-source-file-error.md | 105 ++++++++++++++ 5 files changed, 445 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-converting-an-xlsb-file-to-xlsx.md create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-align-the-image-inside-the-cell.md create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-extract-embedded-OLE-files-from-an-Excel-workbook-as-streams.md create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-cannot-open-Pivot-table-source-file-error.md diff --git a/Document-Processing/Excel/Excel-Library/NET/Slicer.md b/Document-Processing/Excel/Excel-Library/NET/Slicer.md index 9b76a0334..b6e94db29 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Slicer.md +++ b/Document-Processing/Excel/Excel-Library/NET/Slicer.md @@ -255,6 +255,102 @@ slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2 {% endhighlight %} {% endtabs %} +### Select a Slicer Item + +The following example shows how to select items in a slicer. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.SlicerCacheItems[0].IsSelected = true; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.SlicerCacheItems[0].IsSelected = true; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Dim slicer As ISlicer = sheet.Slicers(0) +Dim cache As ISlicerCache = slicer.SlicerCache +cache.SlicerCacheItems(0).IsSelected = True +{% endhighlight %} +{% endtabs %} + +### Select slicer filter type + +The following example shows how to select the slicer filter type. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Dim slicer As ISlicer = sheet.Slicers(0) +Dim cache As ISlicerCache = slicer.SlicerCache +cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop +{% endhighlight %} +{% endtabs %} + +### Sort the slicer items + +The following example shows how to sort the slicer items. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.IsAscending = true; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.IsAscending = true; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Dim slicer As ISlicer = sheet.Slicers(0) +Dim cache As ISlicerCache = slicer.SlicerCache +cache.IsAscending = True +{% endhighlight %} +{% endtabs %} + +### Sort the slicer items using Custom list sorting option + +The following example shows how to sort the slicer items using Custom list sorting option + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.UseCustomListSorting = true; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +ISlicer slicer = sheet.Slicers[0]; +ISlicerCache cache = slicer.SlicerCache; +cache.UseCustomListSorting = true; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Dim slicer As ISlicer = sheet.Slicers(0) +Dim cache As ISlicerCache = slicer.SlicerCache +cache.UseCustomListSorting = True +{% endhighlight %} +{% endtabs %} + The following code snippet illustrates how to format an existing slicer with all the above discussed properties. {% tabs %} @@ -301,6 +397,19 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Slicer style slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2; + + //Select the slicer item + ISlicerCache cache = slicer.SlicerCache; + cache.SlicerCacheItems[0].IsSelected = true; + + //Set the slicer filter type + cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop; + + //Sort the slicer items in ascending order + cache.IsAscending = true; + + //Custom list sorting + cache.UseCustomListSorting = true; workbook.SaveAs("Output.xlsx"); } @@ -349,6 +458,19 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Slicer style slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2; + + //Select the slicer item + ISlicerCache cache = slicer.SlicerCache; + cache.SlicerCacheItems[0].IsSelected = true; + + //Set the slicer filter type + cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop; + + //Sort the slicer items in ascending order + cache.IsAscending = true; + + //Custom list sorting + cache.UseCustomListSorting = true; workbook.SaveAs("Output.xlsx"); } @@ -396,6 +518,19 @@ Using excelEngine As ExcelEngine = New ExcelEngine 'Slicer style slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2 + + 'Select the slicer item + Dim cache As ISlicerCache = slicer.SlicerCache + cache.SlicerCacheItems(0).IsSelected = True + + 'Set the slicer filter type + cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop + + 'Sort the slicer items in ascending order + cache.IsAscending = True + + 'Custom list sorting + cache.UseCustomListSorting = True workbook.SaveAs("Output.xlsx") End Using diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-converting-an-xlsb-file-to-xlsx.md b/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-converting-an-xlsb-file-to-xlsx.md new file mode 100644 index 000000000..6613de80a --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-converting-an-xlsb-file-to-xlsx.md @@ -0,0 +1,56 @@ +--- +title: Convert XLSB to XLSX using XlsIO | Syncfusion +description: This page explains how to convert an XLSB file to XLSX with the Syncfusion .NET Excel (XlsIO) library. +platform: document-processing +control: XlsIO +documentation: UG +--- + +# Does XlsIO support converting an XLSB file to XLSX? + +Yes. XlsIO supports converting an XLSB file to XLSX; however, the conversion is limited to cell values and cell styles. + +The example below shows how to convert an XLSB file to an XLSX file. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Open an existing XLSB file + IWorkbook workbook = application.Workbooks.Open("Sample.xlsb"); + + //Save the file as XLSX + workbook.SaveAs("Output.xlsx"); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Open an existing XLSB file + IWorkbook workbook = application.Workbooks.Open("Sample.xlsb"); + + //Save the file as XLSX + 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 + + ' Open an existing XLSB file + Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsb") + + ' Save the file as XLSX + workbook.SaveAs("Output.xlsx") +End Using +{% endhighlight %} +{% endtabs %} \ No newline at end of file diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-align-the-image-inside-the-cell.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-align-the-image-inside-the-cell.md new file mode 100644 index 000000000..dda7b99b4 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-align-the-image-inside-the-cell.md @@ -0,0 +1,106 @@ +--- +title: Align a picture inside a cell in an Excel worksheet | Syncfusion +description: Learn how to align an image precisely within a worksheet cell using the Syncfusion .NET Excel (XlsIO) library, including positioning, fitting to the cell. +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to align a picture inside a cell in an Excel worksheet? +Image can be aligned in the cell as required using the **TopRowOffset** and **LeftColumnOffset** properties of **ShapeImpl**. In the Microsoft Excel UI, the image is dragged to the required position manually. In the same way, there are no specific values for this property. The values can only be assigned manually. + +The following example shows how to align a picture inside a worksheet cell using the Syncfusion .NET Excel (XlsIO) library. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + int row = 2; + int column = 3; + + //Adding a picture + FileStream imageStream = new FileStream("../../../Data/Image.png", FileMode.Open, FileAccess.Read); + IPictureShape shape = worksheet.Pictures.AddPicture(row, column, imageStream); + + //Insert the image into the cell + (shape as ShapeImpl).Height = worksheet.GetRowHeightInPixels(row); + (shape as ShapeImpl).Width = worksheet.GetColumnWidthInPixels(column); + + //Algin the image inside the cell + (shape as ShapeImpl).TopRowOffset = 50; + (shape as ShapeImpl).LeftColumnOffset = 50; + + #region Save + //Saving the workbook + workbook.SaveAs("../../../Output/Picture.xlsx"); + #endregion + + //Dispose streams + imageStream.Dispose(); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + int row = 2; + int column = 3; + + //Adding a picture + string image = "../../Data/Image.png"; + IPictureShape shape = worksheet.Pictures.AddPicture(row, column, image); + + // Insert the image into the cell + (shape as ShapeImpl).Height = worksheet.GetRowHeightInPixels(row); + (shape as ShapeImpl).Width = worksheet.GetColumnWidthInPixels(column); + + //Algin the image inside the cell + (shape as ShapeImpl).TopRowOffset = 50; + (shape as ShapeImpl).LeftColumnOffset = 50; + + #region Save + //Saving the workbook + workbook.SaveAs("../../Output/Picture.xlsx"); + #endregion +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + + Dim workbook As IWorkbook = application.Workbooks.Create(1) + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + Dim row As Integer = 2 + Dim column As Integer = 3 + + ' Adding a picture + Dim image As String = "../../Data/Image.png" + Dim shape As IPictureShape = worksheet.Pictures.AddPicture(row, column, image) + + ' Insert the image into the cell + Dim impl As ShapeImpl = CType(shape, ShapeImpl) + impl.Height = worksheet.GetRowHeightInPixels(row) + impl.Width = worksheet.GetColumnWidthInPixels(column) + + ' Align the image inside the cell + impl.TopRowOffset = 50 + impl.LeftColumnOffset = 50 + + ' Save + workbook.SaveAs("../../Output/Picture.xlsx") + End Using +{% endhighlight %} +{% endtabs %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-extract-embedded-OLE-files-from-an-Excel-workbook-as-streams.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-extract-embedded-OLE-files-from-an-Excel-workbook-as-streams.md new file mode 100644 index 000000000..db2172994 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-extract-embedded-OLE-files-from-an-Excel-workbook-as-streams.md @@ -0,0 +1,43 @@ +--- +title: Extract embedded OLE files from Excel as streams | Syncfusion +description: This page shows how to extract embedded OLE objects from Excel as streams using the Syncfusion .NET Excel (XlsIO) library. +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to extract embedded OLE files from an Excel workbook as streams? + +You can extract OLE objects in an Excel workbook as streams using XlsIO. The following example demonstrates how to retrieve embedded files from a worksheet. +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + //Create worksheet + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + FileStream embedStream = new FileStream("../../../Sample.docx", FileMode.Open); + FileStream imageStream = new FileStream("../../../wordIcon.jpg", FileMode.Open); + + //Create image stream + Image image = Image.FromStream(imageStream); + + //Add ole object + IOleObject oleObject = worksheet.OleObjects.Add(embedStream, image, OleObjectType.WordDocument); + + // Get the OLE part stream. + Image image1 = Image.FromStream(worksheet.OleObjects[0].GetEmbeddedOleStream()); + MemoryStream memory = new MemoryStream(image1.ImageData); + + //Saving the workbook as stream + FileStream stream = new FileStream("ExtractedFile.xlsx", FileMode.Create, FileAccess.Write); + memory.CopyTo(stream); + workbook.SaveAs(stream); + stream.Dispose(); +} +{% endhighlight %} + +{% endtabs %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-cannot-open-Pivot-table-source-file-error.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-cannot-open-Pivot-table-source-file-error.md new file mode 100644 index 000000000..b4c9fae10 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-cannot-open-Pivot-table-source-file-error.md @@ -0,0 +1,105 @@ +--- +title: Fix “Can't open PivotTable source file” error in XlsIO | Syncfusion +description: This page explains how to resolve the "Can't open Pivottable source file" error using Syncfusion .NET Excel library (XlsIO). +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to resolve the “Can't open Pivot table source file” error? + +Deleting the source worksheet and refreshing the PivotTable may work in the current session, but reopening the saved workbook and refreshing can trigger this error. If “Refresh data when opening the file” is enabled, Excel will not disable it automatically. This is Microsoft Excel behavior, and XlsIO follows the same behavior. + +**Recommendations:** + +* If you need to remove the worksheet that contains the PivotTable’s source data, hide the worksheet instead of deleting it. +* If the source worksheet no longer exists, disable IsRefreshOnLoad before saving the workbook. + +The following code illustrate how to disable the IsRefreshOnLoad property. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("Data/Sample.xlsx"); + IWorksheet pivotSheet = workbook.Worksheets[0]; + + IPivotTable pivotTable = workbook.Worksheets[1].PivotTables[0]; + PivotTableImpl pivotTableImpl = pivotTable as PivotTableImpl; + + //Disable the refreshing option + pivotTableImpl.Cache.IsRefreshOnLoad = false; + + #region Save + //Saving the workbook + workbook.SaveAs("Output/PivotTable.xlsx"); + #endregion +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("Data/Sample.xlsx"); + IWorksheet pivotSheet = workbook.Worksheets[0]; + + IPivotTable pivotTable = workbook.Worksheets[1].PivotTables[0]; + PivotTableImpl pivotTableImpl = pivotTable as PivotTableImpl; + + //Disable the refreshing option + pivotTableImpl.Cache.IsRefreshOnLoad = false; + + #region Save + //Saving the workbook + workbook.SaveAs("Output/PivotTable.xlsx"); + #endregion +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + + Dim workbook As IWorkbook = application.Workbooks.Open("../../Data/Sample.xlsx") + Dim pivotSheet As IWorksheet = workbook.Worksheets(0) + Dim pivotTable As IPivotTable = workbook.Worksheets(1).PivotTables(0) + Dim pivotTableImpl As PivotTableImpl = TryCast(pivotTable, PivotTableImpl) + + ' Disable the refreshing option + pivotTableImpl.Cache.IsRefreshOnLoad = False + + ' Save the workbook + workbook.SaveAs("../../Output/PivotTable.xlsx") +End Using +{% endhighlight %} +{% endtabs %} + + +The following code shows how to hide Excel worksheet. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +//Hide the worksheet +worksheet.Visibility = WorksheetVisibility.Hidden; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +//Hide the worksheet +worksheet.Visibility = WorksheetVisibility.Hidden; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'Hide the worksheet +worksheet.Visibility = WorksheetVisibility.Hidden +{% endhighlight %} +{% endtabs %} + +## See Also + +* [Hide Excel Worksheets](https://help.syncfusion.com/document-processing/excel/excel-library/net/migrate-from-office-automation-to-syncfusion-xlsio/hide-excel-worksheets) +* [Working with Pivot Tables](https://help.syncfusion.com/document-processing/excel/excel-library/net/working-with-pivot-tables)