Skip to content

Commit 02ebebe

Browse files
authored
Merge pull request #1998 from syncfusion-content/Nov2sprint
Update the missing PR Changes for November second sprint
2 parents ce40c3c + 1849399 commit 02ebebe

6 files changed

+616
-0
lines changed

Document-Processing/Excel/Excel-Library/NET/Slicer.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,102 @@ slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2
255255
{% endhighlight %}
256256
{% endtabs %}
257257

258+
### Select a Slicer Item
259+
260+
The following example shows how to select items in a slicer.
261+
262+
{% tabs %}
263+
{% highlight c# tabtitle="C# [Cross-platform]" %}
264+
ISlicer slicer = sheet.Slicers[0];
265+
ISlicerCache cache = slicer.SlicerCache;
266+
cache.SlicerCacheItems[0].IsSelected = true;
267+
{% endhighlight %}
268+
269+
{% highlight c# tabtitle="C# [Windows-specific]" %}
270+
ISlicer slicer = sheet.Slicers[0];
271+
ISlicerCache cache = slicer.SlicerCache;
272+
cache.SlicerCacheItems[0].IsSelected = true;
273+
{% endhighlight %}
274+
275+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
276+
Dim slicer As ISlicer = sheet.Slicers(0)
277+
Dim cache As ISlicerCache = slicer.SlicerCache
278+
cache.SlicerCacheItems(0).IsSelected = True
279+
{% endhighlight %}
280+
{% endtabs %}
281+
282+
### Select slicer filter type
283+
284+
The following example shows how to select the slicer filter type.
285+
286+
{% tabs %}
287+
{% highlight c# tabtitle="C# [Cross-platform]" %}
288+
ISlicer slicer = sheet.Slicers[0];
289+
ISlicerCache cache = slicer.SlicerCache;
290+
cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
291+
{% endhighlight %}
292+
293+
{% highlight c# tabtitle="C# [Windows-specific]" %}
294+
ISlicer slicer = sheet.Slicers[0];
295+
ISlicerCache cache = slicer.SlicerCache;
296+
cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
297+
{% endhighlight %}
298+
299+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
300+
Dim slicer As ISlicer = sheet.Slicers(0)
301+
Dim cache As ISlicerCache = slicer.SlicerCache
302+
cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop
303+
{% endhighlight %}
304+
{% endtabs %}
305+
306+
### Sort the slicer items
307+
308+
The following example shows how to sort the slicer items.
309+
310+
{% tabs %}
311+
{% highlight c# tabtitle="C# [Cross-platform]" %}
312+
ISlicer slicer = sheet.Slicers[0];
313+
ISlicerCache cache = slicer.SlicerCache;
314+
cache.IsAscending = true;
315+
{% endhighlight %}
316+
317+
{% highlight c# tabtitle="C# [Windows-specific]" %}
318+
ISlicer slicer = sheet.Slicers[0];
319+
ISlicerCache cache = slicer.SlicerCache;
320+
cache.IsAscending = true;
321+
{% endhighlight %}
322+
323+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
324+
Dim slicer As ISlicer = sheet.Slicers(0)
325+
Dim cache As ISlicerCache = slicer.SlicerCache
326+
cache.IsAscending = True
327+
{% endhighlight %}
328+
{% endtabs %}
329+
330+
### Sort the slicer items using Custom list sorting option
331+
332+
The following example shows how to sort the slicer items using Custom list sorting option
333+
334+
{% tabs %}
335+
{% highlight c# tabtitle="C# [Cross-platform]" %}
336+
ISlicer slicer = sheet.Slicers[0];
337+
ISlicerCache cache = slicer.SlicerCache;
338+
cache.UseCustomListSorting = true;
339+
{% endhighlight %}
340+
341+
{% highlight c# tabtitle="C# [Windows-specific]" %}
342+
ISlicer slicer = sheet.Slicers[0];
343+
ISlicerCache cache = slicer.SlicerCache;
344+
cache.UseCustomListSorting = true;
345+
{% endhighlight %}
346+
347+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
348+
Dim slicer As ISlicer = sheet.Slicers(0)
349+
Dim cache As ISlicerCache = slicer.SlicerCache
350+
cache.UseCustomListSorting = True
351+
{% endhighlight %}
352+
{% endtabs %}
353+
258354
The following code snippet illustrates how to format an existing slicer with all the above discussed properties.
259355

260356
{% tabs %}
@@ -301,6 +397,19 @@ using (ExcelEngine excelEngine = new ExcelEngine())
301397

302398
//Slicer style
303399
slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2;
400+
401+
//Select the slicer item
402+
ISlicerCache cache = slicer.SlicerCache;
403+
cache.SlicerCacheItems[0].IsSelected = true;
404+
405+
//Set the slicer filter type
406+
cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
407+
408+
//Sort the slicer items in ascending order
409+
cache.IsAscending = true;
410+
411+
//Custom list sorting
412+
cache.UseCustomListSorting = true;
304413

305414
workbook.SaveAs("Output.xlsx");
306415
}
@@ -349,6 +458,19 @@ using (ExcelEngine excelEngine = new ExcelEngine())
349458

350459
//Slicer style
351460
slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2;
461+
462+
//Select the slicer item
463+
ISlicerCache cache = slicer.SlicerCache;
464+
cache.SlicerCacheItems[0].IsSelected = true;
465+
466+
//Set the slicer filter type
467+
cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop;
468+
469+
//Sort the slicer items in ascending order
470+
cache.IsAscending = true;
471+
472+
//Custom list sorting
473+
cache.UseCustomListSorting = true;
352474

353475
workbook.SaveAs("Output.xlsx");
354476
}
@@ -396,6 +518,19 @@ Using excelEngine As ExcelEngine = New ExcelEngine
396518

397519
'Slicer style
398520
slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2
521+
522+
'Select the slicer item
523+
Dim cache As ISlicerCache = slicer.SlicerCache
524+
cache.SlicerCacheItems(0).IsSelected = True
525+
526+
'Set the slicer filter type
527+
cache.CrossFilterType = SlicerCrossFilterType.ShowItemsWithDataAtTop
528+
529+
'Sort the slicer items in ascending order
530+
cache.IsAscending = True
531+
532+
'Custom list sorting
533+
cache.UseCustomListSorting = True
399534

400535
workbook.SaveAs("Output.xlsx")
401536
End Using
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Convert XLSB to XLSX using XlsIO | Syncfusion
3+
description: This page explains how to convert an XLSB file to XLSX with the Syncfusion .NET Excel (XlsIO) library.
4+
platform: document-processing
5+
control: XlsIO
6+
documentation: UG
7+
---
8+
9+
# Does XlsIO support converting an XLSB file to XLSX?
10+
11+
Yes. XlsIO supports converting an XLSB file to XLSX; however, the conversion is limited to cell values and cell styles.
12+
13+
The example below shows how to convert an XLSB file to an XLSX file.
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+
//Open an existing XLSB file
23+
IWorkbook workbook = application.Workbooks.Open("Sample.xlsb");
24+
25+
//Save the file as XLSX
26+
workbook.SaveAs("Output.xlsx");
27+
}
28+
{% endhighlight %}
29+
30+
{% highlight c# tabtitle="C# [Windows-specific]" %}
31+
using (ExcelEngine excelEngine = new ExcelEngine())
32+
{
33+
IApplication application = excelEngine.Excel;
34+
application.DefaultVersion = ExcelVersion.Xlsx;
35+
36+
//Open an existing XLSB file
37+
IWorkbook workbook = application.Workbooks.Open("Sample.xlsb");
38+
39+
//Save the file as XLSX
40+
workbook.SaveAs("Output.xlsx");
41+
}
42+
{% endhighlight %}
43+
44+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
45+
Using excelEngine As New ExcelEngine()
46+
Dim application As IApplication = excelEngine.Excel
47+
application.DefaultVersion = ExcelVersion.Xlsx
48+
49+
' Open an existing XLSB file
50+
Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsb")
51+
52+
' Save the file as XLSX
53+
workbook.SaveAs("Output.xlsx")
54+
End Using
55+
{% endhighlight %}
56+
{% endtabs %}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Align a picture inside a cell in an Excel worksheet | Syncfusion
3+
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.
4+
platform: document-processing
5+
control: XlsIO
6+
documentation: UG
7+
---
8+
9+
# How to align a picture inside a cell in an Excel worksheet?
10+
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.
11+
12+
The following example shows how to align a picture inside a worksheet cell using the Syncfusion .NET Excel (XlsIO) library.
13+
14+
{% tabs %}
15+
{% highlight c# tabtitle="C# [Cross-platform]" %}
16+
using (ExcelEngine excelEngine = new ExcelEngine())
17+
{
18+
IApplication application = excelEngine.Excel;
19+
application.DefaultVersion = ExcelVersion.Xlsx;
20+
IWorkbook workbook = application.Workbooks.Create(1);
21+
IWorksheet worksheet = workbook.Worksheets[0];
22+
23+
int row = 2;
24+
int column = 3;
25+
26+
//Adding a picture
27+
FileStream imageStream = new FileStream("../../../Data/Image.png", FileMode.Open, FileAccess.Read);
28+
IPictureShape shape = worksheet.Pictures.AddPicture(row, column, imageStream);
29+
30+
//Insert the image into the cell
31+
(shape as ShapeImpl).Height = worksheet.GetRowHeightInPixels(row);
32+
(shape as ShapeImpl).Width = worksheet.GetColumnWidthInPixels(column);
33+
34+
//Algin the image inside the cell
35+
(shape as ShapeImpl).TopRowOffset = 50;
36+
(shape as ShapeImpl).LeftColumnOffset = 50;
37+
38+
#region Save
39+
//Saving the workbook
40+
workbook.SaveAs("../../../Output/Picture.xlsx");
41+
#endregion
42+
43+
//Dispose streams
44+
imageStream.Dispose();
45+
}
46+
{% endhighlight %}
47+
48+
{% highlight c# tabtitle="C# [Windows-specific]" %}
49+
using (ExcelEngine excelEngine = new ExcelEngine())
50+
{
51+
IApplication application = excelEngine.Excel;
52+
application.DefaultVersion = ExcelVersion.Xlsx;
53+
IWorkbook workbook = application.Workbooks.Create(1);
54+
IWorksheet worksheet = workbook.Worksheets[0];
55+
56+
int row = 2;
57+
int column = 3;
58+
59+
//Adding a picture
60+
string image = "../../Data/Image.png";
61+
IPictureShape shape = worksheet.Pictures.AddPicture(row, column, image);
62+
63+
// Insert the image into the cell
64+
(shape as ShapeImpl).Height = worksheet.GetRowHeightInPixels(row);
65+
(shape as ShapeImpl).Width = worksheet.GetColumnWidthInPixels(column);
66+
67+
//Algin the image inside the cell
68+
(shape as ShapeImpl).TopRowOffset = 50;
69+
(shape as ShapeImpl).LeftColumnOffset = 50;
70+
71+
#region Save
72+
//Saving the workbook
73+
workbook.SaveAs("../../Output/Picture.xlsx");
74+
#endregion
75+
}
76+
{% endhighlight %}
77+
78+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
79+
Using excelEngine As New ExcelEngine()
80+
Dim application As IApplication = excelEngine.Excel
81+
application.DefaultVersion = ExcelVersion.Xlsx
82+
83+
Dim workbook As IWorkbook = application.Workbooks.Create(1)
84+
Dim worksheet As IWorksheet = workbook.Worksheets(0)
85+
86+
Dim row As Integer = 2
87+
Dim column As Integer = 3
88+
89+
' Adding a picture
90+
Dim image As String = "../../Data/Image.png"
91+
Dim shape As IPictureShape = worksheet.Pictures.AddPicture(row, column, image)
92+
93+
' Insert the image into the cell
94+
Dim impl As ShapeImpl = CType(shape, ShapeImpl)
95+
impl.Height = worksheet.GetRowHeightInPixels(row)
96+
impl.Width = worksheet.GetColumnWidthInPixels(column)
97+
98+
' Align the image inside the cell
99+
impl.TopRowOffset = 50
100+
impl.LeftColumnOffset = 50
101+
102+
' Save
103+
workbook.SaveAs("../../Output/Picture.xlsx")
104+
End Using
105+
{% endhighlight %}
106+
{% endtabs %}

0 commit comments

Comments
 (0)