Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
1f7d9dd
Add example: create-a-new-worksheet-table-from-a-range-of-cells-and-a…
agent-aspose-cells-examples May 22, 2026
38cd9a9
Add example: apply-a-predefined-table-style-to-the-created-table-and-…
agent-aspose-cells-examples May 22, 2026
70e2af7
Add example: add-a-totals-row-to-the-table-and-configure-sum-formulas…
agent-aspose-cells-examples May 22, 2026
91e22f3
Add example: set-a-custom-formula-in-the-totals-row-to-calculate-aver…
agent-aspose-cells-examples May 22, 2026
4bc403d
Add example: hide-the-table-header-row-while-keeping-the-data-rows-vi…
agent-aspose-cells-examples May 22, 2026
f3b88fd
Add example: enable-autofilter-on-the-table-and-define-a-filter-to-sh…
agent-aspose-cells-examples May 22, 2026
f3c32e8
Add example: sort-the-table-by-two-columns-first-ascending-by-date-th…
agent-aspose-cells-examples May 22, 2026
1b6182d
Add example: group-rows-within-the-table-based-on-category-column-and…
agent-aspose-cells-examples May 22, 2026
7e85163
Add example: protect-the-entire-table-with-a-password-allowing-only-r…
agent-aspose-cells-examples May 22, 2026
e862ffe
Add example: unprotect-the-previously-secured-table-using-the-correct…
agent-aspose-cells-examples May 22, 2026
501c536
Add example: lock-specific-columns-in-the-table-to-prevent-accidental…
agent-aspose-cells-examples May 22, 2026
720559a
Add example: add-a-comment-to-the-table-object-describing-its-purpose…
agent-aspose-cells-examples May 22, 2026
bb755f4
Add example: update-the-existing-table-comment-to-include-version-inf…
agent-aspose-cells-examples May 22, 2026
ca9a263
Add example: delete-the-comment-attached-to-the-table-to-clean-up-met…
agent-aspose-cells-examples May 22, 2026
652b955
Add example: convert-the-existing-list-object-into-a-structured-table…
agent-aspose-cells-examples May 22, 2026
3dda26f
Add example: create-a-list-object-from-a-dynamic-range-and-enable-aut…
agent-aspose-cells-examples May 22, 2026
95f0eaf
Add example: disable-the-ability-for-users-to-add-new-rows-to-the-lis…
agent-aspose-cells-examples May 22, 2026
7b1e866
Add example: enable-the-list-objects-header-row-and-customize-its-bac…
agent-aspose-cells-examples May 22, 2026
9542e81
Add example: set-the-list-object-to-display-a-totals-row-and-configur…
agent-aspose-cells-examples May 22, 2026
06e18ba
Add example: load-an-existing-excel-workbook-containing-query-tables-…
agent-aspose-cells-examples May 22, 2026
31688f0
Add example: set-the-background-refresh-property-of-a-query-table-to-…
agent-aspose-cells-examples May 22, 2026
a7208e3
Add example: export-the-data-from-a-query-table-to-a-csv-file-while-p…
agent-aspose-cells-examples May 22, 2026
17c04be
Add example: read-the-metadata-of-a-query-table-including-connection-…
agent-aspose-cells-examples May 22, 2026
1981504
Add example: write-a-datatable-object-into-a-new-worksheet-table-mapp…
agent-aspose-cells-examples May 22, 2026
a4bd1b2
Add example: load-a-workbook-locate-a-table-by-name-and-export-its-co…
agent-aspose-cells-examples May 22, 2026
03d8523
Add example: create-a-chart-that-uses-a-worksheet-table-as-its-data-s…
agent-aspose-cells-examples May 22, 2026
2418695
Add example: refresh-all-pivot-tables-that-reference-a-specific-works…
agent-aspose-cells-examples May 22, 2026
7d319bc
Add example: apply-conditional-formatting-to-a-table-column-that-high…
agent-aspose-cells-examples May 22, 2026
cef9c71
Add example: autofit-all-columns-of-a-table-to-match-the-longest-cell…
agent-aspose-cells-examples May 22, 2026
192e9da
Add example: set-a-custom-column-width-for-a-specific-table-column-to…
agent-aspose-cells-examples May 22, 2026
f24852d
Add example: hide-a-table-column-programmatically-and-later-unhide-it…
agent-aspose-cells-examples May 22, 2026
268aab5
Add example: create-a-duplicate-of-an-existing-table-on-another-works…
agent-aspose-cells-examples May 22, 2026
358f189
Add example: validate-that-a-table-contains-no-duplicate-rows-based-o…
agent-aspose-cells-examples May 22, 2026
2fd1c37
Add example: insert-a-new-row-into-a-table-and-automatically-copy-the…
agent-aspose-cells-examples May 22, 2026
2a32496
Add example: delete-a-specific-row-from-a-table-using-its-primary-key…
agent-aspose-cells-examples May 22, 2026
21ee02f
Add example: apply-a-unique-index-to-a-table-column-to-enforce-data-u…
agent-aspose-cells-examples May 22, 2026
4bcd174
Add example: export-a-worksheet-table-to-a-json-string-preserving-col…
agent-aspose-cells-examples May 22, 2026
9413e88
Add example: import-json-data-into-a-new-table-automatically-creating…
agent-aspose-cells-examples May 22, 2026
a933502
Add example: calculate-a-running-total-column-within-a-table-using-a-…
agent-aspose-cells-examples May 22, 2026
17bb458
Add example: set-the-tables-show-totals-row-option-to-false-removing-…
agent-aspose-cells-examples May 22, 2026
43d30d5
Add example: enable-the-tables-autoexpand-feature-so-that-adding-data…
agent-aspose-cells-examples May 22, 2026
2f9d479
Add example: create-a-table-with-a-calculated-column-that-concatenate…
agent-aspose-cells-examples May 22, 2026
00321e1
Add example: apply-a-builtin-table-style-that-matches-the-workbooks-t…
agent-aspose-cells-examples May 22, 2026
927dac4
Add example: change-the-table-style-to-a-custom-xmldefined-style-to-m…
agent-aspose-cells-examples May 22, 2026
71ce17b
Add example: add-a-slicer-linked-to-a-table-column-to-provide-interac…
agent-aspose-cells-examples May 22, 2026
c228b4c
Add example: remove-an-existing-slicer-from-a-table-and-clean-up-asso…
agent-aspose-cells-examples May 22, 2026
71aec50
Add example: programmatically-retrieve-the-address-range-of-a-table-a…
agent-aspose-cells-examples May 22, 2026
f6f9abb
Add example: create-a-data-validation-list-that-pulls-its-items-direc…
agent-aspose-cells-examples May 22, 2026
c683e34
Add example: set-the-tables-show-header-row-option-to-false-for-a-com…
agent-aspose-cells-examples May 22, 2026
9956be0
Add example: enable-the-tables-show-header-row-option-and-customize-t…
agent-aspose-cells-examples May 22, 2026
bcc1edb
Add example: reorder-columns-in-a-table-to-match-a-predefined-layout-…
agent-aspose-cells-examples May 22, 2026
dc3c8a5
Add example: apply-a-filter-that-selects-rows-where-the-status-column…
agent-aspose-cells-examples May 22, 2026
7ae8603
Add example: clear-all-filters-applied-to-a-table-restoring-the-full-…
agent-aspose-cells-examples May 22, 2026
bb8f86b
Add example: create-a-table-from-an-external-csv-file-using-a-query-t…
agent-aspose-cells-examples May 22, 2026
56a9c49
Add example: configure-a-query-table-to-use-windows-authentication-fo…
agent-aspose-cells-examples May 22, 2026
5462ed6
Add example: export-a-worksheet-containing-multiple-tables-to-a-singl…
agent-aspose-cells-examples May 22, 2026
bde57b5
Add example: create-a-macroenabled-workbook-add-a-table-and-assign-a-…
agent-aspose-cells-examples May 22, 2026
eab87bc
Add example: validate-that-a-tables-column-data-types-match-expected-…
agent-aspose-cells-examples May 22, 2026
b899a72
Add example: generate-a-summary-worksheet-that-aggregates-values-from…
agent-aspose-cells-examples May 22, 2026
0046921
Add example: apply-a-custom-number-format-to-a-numeric-column-in-a-ta…
agent-aspose-cells-examples May 22, 2026
20b4a3b
Add example: set-the-tables-show-totals-row-option-and-configure-a-cu…
agent-aspose-cells-examples May 22, 2026
11ccf60
Add example: create-a-table-with-a-header-row-that-uses-merged-cells-…
agent-aspose-cells-examples May 22, 2026
0d38731
Add example: programmatically-detect-tables-that-lack-a-totals-row-an…
agent-aspose-cells-examples May 22, 2026
dab973c
Add example: import-data-from-an-xml-file-into-a-new-table-mapping-xm…
agent-aspose-cells-examples May 22, 2026
fdcf662
Add example: apply-a-filter-that-excludes-rows-where-the-date-column-…
agent-aspose-cells-examples May 22, 2026
bdf758d
Add example: create-a-table-then-generate-a-named-range-that-referenc…
agent-aspose-cells-examples May 22, 2026
1ccb652
Add example: set-the-tables-show-header-row-option-to-true-and-lock-t…
agent-aspose-cells-examples May 22, 2026
bc2cc19
Add example: add-a-calculated-column-that-uses-the-if-function-to-cat…
agent-aspose-cells-examples May 22, 2026
fd9a7e2
Add example: remove-duplicate-rows-from-a-table-based-on-a-composite-…
agent-aspose-cells-examples May 22, 2026
2d77fb2
Add example: create-a-table-then-attach-a-comment-that-includes-a-hyp…
agent-aspose-cells-examples May 22, 2026
d81e7a0
Add example: programmatically-change-the-tables-style-to-tablestyleli…
agent-aspose-cells-examples May 22, 2026
c262dcb
Add example: enable-the-tables-autofilter-feature-and-set-a-custom-cr…
agent-aspose-cells-examples May 22, 2026
b5e6e41
Add example: add-a-new-row-to-a-table-and-populate-it-with-values-fro…
agent-aspose-cells-examples May 22, 2026
9cc5534
Add example: delete-all-rows-from-a-table-that-have-a-null-value-in-a…
agent-aspose-cells-examples May 22, 2026
d9e6b4e
Add example: create-a-table-then-generate-a-pivot-chart-from-its-data…
agent-aspose-cells-examples May 22, 2026
ea64c82
Add example: export-a-table-to-a-json-file-with-indentation-for-reada…
agent-aspose-cells-examples May 22, 2026
ed2382d
Add example: import-a-json-array-into-a-table-automatically-creating-…
agent-aspose-cells-examples May 22, 2026
ed5b18d
Add example: apply-a-custom-cell-style-to-a-tables-totals-row-to-diff…
agent-aspose-cells-examples May 22, 2026
e8a93d9
Add example: set-the-tables-show-totals-row-option-and-configure-a-cu…
agent-aspose-cells-examples May 22, 2026
63a7b1f
Add example: add-a-slicer-linked-to-a-table-column-and-configure-it-t…
agent-aspose-cells-examples May 22, 2026
74cc143
Add example: remove-all-slicers-associated-with-a-specific-table-to-s…
agent-aspose-cells-examples May 22, 2026
ff5d32a
Add example: create-a-table-then-generate-a-data-validation-rule-rest…
agent-aspose-cells-examples May 22, 2026
912034e
Add example: programmatically-copy-a-tables-style-to-another-table-to…
agent-aspose-cells-examples May 22, 2026
92de202
Add example: set-a-tables-column-to-use-a-custom-date-format-ddmmmyyy…
agent-aspose-cells-examples May 22, 2026
32f60cd
Add example: enable-the-tables-autofilter-and-apply-a-custom-filter-s…
agent-aspose-cells-examples May 22, 2026
4f53a82
Add example: create-a-table-then-attach-a-comment-that-includes-the-c…
agent-aspose-cells-examples May 22, 2026
12520a4
Add example: refresh-a-query-table-after-modifying-its-underlying-sql…
agent-aspose-cells-examples May 22, 2026
c1e50b6
Add example: import-data-from-a-csv-file-into-a-new-table-and-automat…
agent-aspose-cells-examples May 22, 2026
e22d984
Add example: create-a-table-then-generate-a-chart-that-uses-the-table…
agent-aspose-cells-examples May 22, 2026
cf621f1
Add example: apply-conditional-formatting-to-highlight-duplicate-valu…
agent-aspose-cells-examples May 22, 2026
d979f12
Add example: set-the-tables-show-header-row-option-to-true-and-apply-…
agent-aspose-cells-examples May 22, 2026
fb6dd3d
Add example: create-a-table-with-a-calculated-column-using-the-today-…
agent-aspose-cells-examples May 22, 2026
5db00e3
Add example: programmatically-detect-tables-lacking-a-header-row-and-…
agent-aspose-cells-examples May 22, 2026
400698b
Add example: add-a-column-to-a-table-and-set-its-validation-to-a-list…
agent-aspose-cells-examples May 22, 2026
a6718f7
Add example: remove-a-tables-totals-row-and-then-readd-it-with-custom…
agent-aspose-cells-examples May 22, 2026
88a337d
Add example: create-a-table-then-generate-a-named-range-that-referenc…
agent-aspose-cells-examples May 22, 2026
b796c6c
Add example: apply-a-table-style-that-uses-alternating-row-colors-to-…
agent-aspose-cells-examples May 22, 2026
76c6019
Add example: export-a-table-to-an-html-file-preserving-table-structur…
agent-aspose-cells-examples May 22, 2026
8f64b56
Add example: import-an-html-table-into-a-worksheet-converting-it-into…
agent-aspose-cells-examples May 22, 2026
848f4d5
Add example: create-a-table-then-attach-a-comment-that-includes-a-hyp…
agent-aspose-cells-examples May 22, 2026
9380d14
Add example: load-a-workbook-and-convert-a-specific-table-to-a-range-…
agent-aspose-cells-examples May 22, 2026
3b486e9
Add example: retrieve-a-table-from-a-cell-using-cellgettable-and-inse…
agent-aspose-cells-examples May 22, 2026
62944d9
Add example: use-listobjectputcellvalue-with-row-and-column-offsets-t…
agent-aspose-cells-examples May 22, 2026
38f1384
Add example: convert-a-table-to-a-range-retaining-formatting-only-for…
agent-aspose-cells-examples May 22, 2026
fef0bb3
Add example: verify-that-after-conversion-the-table-no-longer-support…
agent-aspose-cells-examples May 22, 2026
166a194
Add example: apply-tabletorangeoptionslastrow-to-keep-formatting-thro…
agent-aspose-cells-examples May 22, 2026
19f911b
Add example: save-the-workbook-containing-the-converted-range-as-ods-…
agent-aspose-cells-examples May 22, 2026
88530ea
Add example: insert-a-formula-into-a-table-cell-using-cellputvalue-wi…
agent-aspose-cells-examples May 22, 2026
f18796b
Add example: use-listobjectputcellvalue-to-add-a-date-value-at-row-of…
agent-aspose-cells-examples May 22, 2026
95426ee
Add example: iterate-through-all-tables-in-a-workbook-and-convert-eac…
agent-aspose-cells-examples May 22, 2026
4f0e135
Add example: after-conversion-attempt-to-apply-a-filter-to-the-former…
agent-aspose-cells-examples May 22, 2026
60f2c2b
Add example: load-a-workbook-retrieve-a-table-via-cellgettable-and-re…
agent-aspose-cells-examples May 22, 2026
3be07bd
Add example: use-tabletorangeoptions-to-preserve-formatting-for-the-h…
agent-aspose-cells-examples May 22, 2026
04f866b
Add example: batch-process-multiple-worksheets-converting-each-table-…
agent-aspose-cells-examples May 22, 2026
7af7b9e
Add example: set-tabletorangeoptionslastrow-to-zero-to-remove-all-for…
agent-aspose-cells-examples May 22, 2026
4ca4365
Add example: use-listobjectputcellvalue-to-insert-a-hyperlink-string-…
agent-aspose-cells-examples May 22, 2026
752a21d
Add example: validate-that-after-conversion-the-workbook-no-longer-co…
agent-aspose-cells-examples May 22, 2026
56bbe6f
Add example: convert-a-table-to-a-range-preserving-formatting-up-to-t…
agent-aspose-cells-examples May 22, 2026
fce499b
Add example: apply-tabletorangeoptionslastrow-to-retain-formatting-fo…
agent-aspose-cells-examples May 22, 2026
ac275aa
Add example: retrieve-a-table-with-cellgettable-and-enumerate-its-row…
agent-aspose-cells-examples May 22, 2026
ff35ec1
Add example: use-listobjectputcellvalue-to-add-a-boolean-value-at-a-s…
agent-aspose-cells-examples May 22, 2026
efcfd88
Add example: convert-a-table-to-a-range-preserving-formatting-for-the…
agent-aspose-cells-examples May 22, 2026
1a10569
Add example: insert-a-multi-line-string-into-a-table-cell-using-listo…
agent-aspose-cells-examples May 22, 2026
f7ac00b
Add example: convert-a-table-to-a-range-and-copy-the-resulting-range-…
agent-aspose-cells-examples May 22, 2026
883f41a
Add example: define-tabletorangeoptionslastrow-dynamically-based-on-l…
agent-aspose-cells-examples May 22, 2026
1baf74b
Add example: insert-a-calculated-total-value-at-the-bottom-of-a-table…
agent-aspose-cells-examples May 22, 2026
49180db
Add example: convert-a-table-to-a-range-preserving-formatting-for-the…
agent-aspose-cells-examples May 22, 2026
1458ce1
Add example: overwrite-an-existing-value-in-a-table-cell-using-cellpu…
agent-aspose-cells-examples May 22, 2026
67bc5d6
Add example: use-listobjectputcellvalue-to-insert-a-string-value-into…
agent-aspose-cells-examples May 22, 2026
97376c1
Add example: after-converting-a-table-to-a-range-attempt-to-apply-sor…
agent-aspose-cells-examples May 22, 2026
839bbec
Add example: convert-a-query-table-into-a-regular-worksheet-table-ret…
agent-aspose-cells-examples May 22, 2026
5dc926c
Add example: generate-a-pivot-table-based-on-an-existing-worksheet-ta…
agent-aspose-cells-examples May 22, 2026
e605a60
Add example: disable-autoexpand-for-a-table-to-keep-its-range-fixed-d…
agent-aspose-cells-examples May 22, 2026
be31c81
Add example: update-the-named-range-that-references-a-table-after-exp…
agent-aspose-cells-examples May 22, 2026
edab4c6
Add example: remove-an-unwanted-column-from-a-table-while-preserving-…
agent-aspose-cells-examples May 22, 2026
974af71
Add example: export-a-specific-table-to-an-xml-file-using-the-excel-x…
agent-aspose-cells-examples May 22, 2026
0b8f13f
Add example: create-a-table-with-a-dynamic-named-range-that-expands-a…
agent-aspose-cells-examples May 22, 2026
209be31
Add example: export-all-tables-in-a-workbook-to-separate-csv-files-na…
agent-aspose-cells-examples May 22, 2026
08776d3
Add example: set-the-query-tables-connection-string-to-use-integrated…
agent-aspose-cells-examples May 22, 2026
b5a73bd
Update agents.md
agent-aspose-cells-examples May 31, 2026
4fe31f2
Resolve index.json merge conflicts with release/26.5.0
agent-aspose-cells-examples May 31, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Aspose.Cells;
using System;

class Program
{
static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;

// Populate sample numeric data in column A
cells["A1"].PutValue("Value");
cells["A2"].PutValue(50);
cells["A3"].PutValue(150);
cells["A4"].PutValue(80);
cells["A5"].PutValue(200);

// Add header for the calculated column in column B
cells["B1"].PutValue("Category");

// Define the numeric threshold for categorization
double threshold = 100;

// Apply IF formula to each row to categorize based on the threshold
for (int row = 2; row <= 5; row++)
{
// Formula: =IF(A{row}>threshold,"High","Low")
string formula = $"=IF(A{row}>{threshold},\"High\",\"Low\")";
cells[$"B{row}"].Formula = formula;
}

// Calculate all formulas in the workbook
workbook.CalculateFormula();

// Save the workbook to a file
workbook.Save("CalculatedColumn.xlsx");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using Aspose.Cells;
using Aspose.Cells.Tables; // Required for ListObject

namespace AsposeCellsTableValidationDemo
{
class Program
{
static void Main()
{
try
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;

// Populate sample data (including the source list column)
// Header row
cells["A1"].PutValue("ID");
cells["B1"].PutValue("Options"); // This column will be the source list
cells["C1"].PutValue("Value");
cells["D1"].PutValue("Choice"); // Column that will have validation

// Data rows
for (int i = 2; i <= 5; i++)
{
cells[$"A{i}"].PutValue(i - 1); // ID
cells[$"B{i}"].PutValue($"Option{i - 1}"); // Options (source list)
cells[$"C{i}"].PutValue((i - 1) * 10); // Some other value
// D column left empty – will receive validation
}

// Add a ListObject (table) that includes the new column D
// Table range: A1:D5, hasHeaders = true
int tableIndex = sheet.ListObjects.Add("A1", "D5", true);
ListObject table = sheet.ListObjects[tableIndex];
// Use DisplayName to set the table name (Name property not available in some versions)
table.DisplayName = "SampleTable";

// Define the area for validation: column D (index 3), rows 2‑5 (excluding header)
CellArea validationArea = CellArea.CreateCellArea(1, 3, 4, 3); // rows 1‑4 zero‑based, column 3

// Add validation to the worksheet
ValidationCollection validations = sheet.Validations;
int validationIndex = validations.Add(validationArea);
Validation validation = validations[validationIndex];

// Configure validation as a list sourced from the "Options" column (B2:B5)
validation.Type = ValidationType.List;
validation.InCellDropDown = true;
validation.Formula1 = "$B$2:$B$5"; // absolute reference to source list range

// Save the workbook
string outputPath = "TableWithDropdownValidation.xlsx";
workbook.Save(outputPath);
Console.WriteLine($"Workbook saved successfully to '{outputPath}'.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using Aspose.Cells;
using Aspose.Cells.Tables;

class ListObjectCommentDemo
{
static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Populate sample data for the table
worksheet.Cells["A1"].PutValue("ID");
worksheet.Cells["B1"].PutValue("Value");
worksheet.Cells["A2"].PutValue(1);
worksheet.Cells["B2"].PutValue(100);
worksheet.Cells["A3"].PutValue(2);
worksheet.Cells["B3"].PutValue(200);

// Add a ListObject (table) that covers the data range A1:B3
int listIndex = worksheet.ListObjects.Add(0, 0, 2, 1, true);
ListObject table = worksheet.ListObjects[listIndex];

// Set a comment describing the purpose of the table
table.Comment = "This table stores IDs and their corresponding values.";

// Retrieve the comment text programmatically and display it
Console.WriteLine("Table Comment: " + table.Comment);

// Save the workbook
workbook.Save("ListObjectWithComment.xlsx", SaveFormat.Xlsx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.IO;
using Aspose.Cells;
using Aspose.Cells.Tables;

namespace AsposeCellsTableExample
{
class Program
{
static void Main()
{
try
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;

// Populate header and a couple of data rows to form a table
cells["A1"].PutValue("ID");
cells["B1"].PutValue("Product");
cells["C1"].PutValue("Price");

cells["A2"].PutValue(1);
cells["B2"].PutValue("Laptop");
cells["C2"].PutValue(999.99m);

cells["A3"].PutValue(2);
cells["B3"].PutValue("Monitor");
cells["C3"].PutValue(249.99m);

// Create a ListObject (Excel table) covering the data range
int tableIndex = worksheet.ListObjects.Add("A1", "C3", true);
ListObject table = worksheet.ListObjects[tableIndex];

// Dictionary containing values for the new row
var newRowData = new Dictionary<string, object>
{
{ "ID", 3 },
{ "Product", "Keyboard" },
{ "Price", 49.99m }
};

// Determine the row offset for the new row (append at the end)
// DataRange includes the header row, so subtract 1 to get existing data rows count
int newRowOffset = table.DataRange.RowCount - 1;

// Populate each column using the dictionary values
foreach (KeyValuePair<string, object> kvp in newRowData)
{
// Find the column index by header name
int columnIndex = -1;
for (int i = 0; i < table.ListColumns.Count; i++)
{
if (string.Equals(table.ListColumns[i].Name, kvp.Key, StringComparison.OrdinalIgnoreCase))
{
columnIndex = i;
break;
}
}

// If the column exists, put the value; otherwise ignore
if (columnIndex >= 0)
{
table.PutCellValue(newRowOffset, columnIndex, kvp.Value);
}
}

// Save the workbook
string outputPath = "TableWithNewRow.xlsx";
workbook.Save(outputPath);
Console.WriteLine($"Workbook saved to {Path.GetFullPath(outputPath)}");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.IO;
using Aspose.Cells;
using Aspose.Cells.Slicers;
using Aspose.Cells.Tables;

namespace AsposeCellsSlicerExample
{
public class MultiSelectSlicerDemo
{
public static void Run()
{
try
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

// Populate worksheet with sample data for the table
sheet.Cells["A1"].PutValue("Category");
sheet.Cells["B1"].PutValue("Value");
sheet.Cells["A2"].PutValue("A");
sheet.Cells["B2"].PutValue(10);
sheet.Cells["A3"].PutValue("B");
sheet.Cells["B3"].PutValue(20);
sheet.Cells["A4"].PutValue("A");
sheet.Cells["B4"].PutValue(30);
sheet.Cells["A5"].PutValue("C");
sheet.Cells["B5"].PutValue(40);

// Add a table that covers the data range (A1:B5)
int tableIndex = sheet.ListObjects.Add(0, 0, 4, 1, true);
ListObject table = sheet.ListObjects[tableIndex];
table.TableStyleType = TableStyleType.TableStyleMedium2;

// Add a slicer linked to the first column ("Category") of the table
// Placed with its upper‑left corner at row 6, column 2 (cell B6)
SlicerCollection slicers = sheet.Slicers;
int slicerIndex = slicers.Add(table, table.ListColumns[0], 6, 2);
Slicer slicer = slicers[slicerIndex];

// Configure slicer appearance (optional)
slicer.Caption = "Category Filter";
slicer.NumberOfColumns = 2; // layout with two columns for easier multi‑selection

// Use Shape properties instead of obsolete WidthPixel/HeightPixel
slicer.Shape.Width = 200; // width in points
slicer.Shape.Height = 150; // height in points

// Save the workbook
string outputPath = "MultiSelectSlicerDemo.xlsx";
workbook.Save(outputPath);
Console.WriteLine($"Workbook saved to '{Path.GetFullPath(outputPath)}'.");
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error: {ex.Message}");
}
}

// Entry point required for console application
public static void Main(string[] args)
{
Run();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Aspose.Cells;
using Aspose.Cells.Slicers;
using Aspose.Cells.Tables;

namespace AsposeCellsSlicerDemo
{
public class Program
{
public static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

// Populate sample data for the table (A1:B5)
sheet.Cells["A1"].PutValue("Category");
sheet.Cells["B1"].PutValue("Amount");
sheet.Cells["A2"].PutValue("Food");
sheet.Cells["B2"].PutValue(120);
sheet.Cells["A3"].PutValue("Drink");
sheet.Cells["B3"].PutValue(80);
sheet.Cells["A4"].PutValue("Food");
sheet.Cells["B4"].PutValue(150);
sheet.Cells["A5"].PutValue("Snack");
sheet.Cells["B5"].PutValue(60);

// Convert the range into a ListObject (table)
// Add table covering A1:B5 (true indicates the range has headers)
int tableIndex = sheet.ListObjects.Add("A1", "B5", true);
ListObject table = sheet.ListObjects[tableIndex];
table.TableStyleType = TableStyleType.TableStyleMedium2; // optional styling

// Add a slicer linked to the "Category" column of the table
// Use zero‑based row and column indices for the upper‑left corner of the slicer
// Here we place the slicer starting at row 7 (index 6) and column 2 (index 1)
SlicerCollection slicers = sheet.Slicers;
int slicerIndex = slicers.Add(table, table.ListColumns[0], 6, 1);
Slicer slicer = slicers[slicerIndex];

// Optional: customize slicer appearance
slicer.Caption = "Category Filter";
slicer.NumberOfColumns = 1;
slicer.StyleType = SlicerStyleType.SlicerStyleLight1;
slicer.WidthPixel = 150;
slicer.HeightPixel = 120;

// Save the workbook with the slicer
workbook.Save("SlicerLinkedToTable.xlsx");
}
}
}
Loading