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
135 changes: 135 additions & 0 deletions Document-Processing/Excel/Excel-Library/NET/Slicer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
@@ -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 %}
Loading