Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c72cf7a
Add example: load-a-workbook-from-a-file-path-and-obtain-its-dataconn…
agent-aspose-cells-examples May 21, 2026
6f0b5fb
Add example: iterate-through-dataconnections-to-identify-sql-type-con…
agent-aspose-cells-examples May 21, 2026
5ba33ed
Add example: retrieve-commandtext-commandtype-and-connectioninfo-from…
agent-aspose-cells-examples May 21, 2026
0ca9830
Add example: update-username-and-password-properties-of-a-specific-db…
agent-aspose-cells-examples May 21, 2026
e5b63c5
Add example: change-description-property-of-a-dbconnection-to-reflect…
agent-aspose-cells-examples May 21, 2026
f4b00ef
Add example: modify-commandtext-of-a-dbconnection-to-include-a-filter…
agent-aspose-cells-examples May 21, 2026
c2246a8
Add example: set-refreshonload-flag-of-a-webquery-connection-to-true-…
agent-aspose-cells-examples May 21, 2026
94c9699
Add example: enable-backgroundrefresh-on-a-webquery-connection-to-avo…
agent-aspose-cells-examples May 21, 2026
ce7f331
Add example: disable-backgroundrefresh-on-a-sql-dbconnection-to-enfor…
agent-aspose-cells-examples May 21, 2026
95c78f7
Add example: refresh-all-external-data-connections-sequentially-to-en…
agent-aspose-cells-examples May 21, 2026
9e3c24b
Add example: retrieve-the-first-worksheet-access-its-first-querytable…
agent-aspose-cells-examples May 21, 2026
154c0e6
Add example: enable-preserveformatting-on-a-querytable-to-maintain-ce…
agent-aspose-cells-examples May 21, 2026
6cec766
Add example: disable-preserveformatting-on-a-querytable-to-allow-defa…
agent-aspose-cells-examples May 21, 2026
dc92bb2
Add example: iterate-through-all-querytables-in-all-worksheets-and-se…
agent-aspose-cells-examples May 21, 2026
e526de9
Add example: obtain-resultrange-address-of-a-querytable-and-log-it-fo…
agent-aspose-cells-examples May 21, 2026
c226395
Add example: rename-an-existing-dbconnection-to-reflect-a-new-databas…
agent-aspose-cells-examples May 21, 2026
808b7b8
Add example: validate-that-all-external-connections-have-nonempty-cre…
agent-aspose-cells-examples May 21, 2026
af05d00
Add example: save-the-modified-workbook-to-a-new-file-path-preserving…
agent-aspose-cells-examples May 21, 2026
8ac0c6b
Add example: write-a-utility-that-lists-all-worksheets-containing-que…
agent-aspose-cells-examples May 21, 2026
62f8792
Add example: measure-and-log-the-time-taken-to-refresh-each-dbconnect…
agent-aspose-cells-examples May 21, 2026
5e3ca55
Add example: load-an-xls-workbook-using-the-workbook-class-and-access…
agent-aspose-cells-examples May 21, 2026
81ff85e
Add example: extract-odata-connection-details-from-the-datamashup-obj…
agent-aspose-cells-examples May 21, 2026
32fd3c9
Add example: output-each-powerquery-formula-name-to-the-console-for-v…
agent-aspose-cells-examples May 21, 2026
9be6389
Add example: retrieve-the-first-external-dbconnection-from-a-workbook…
agent-aspose-cells-examples May 21, 2026
2434db7
Add example: rename-the-retrieved-dbconnectionname-to-a-descriptive-i…
agent-aspose-cells-examples May 21, 2026
15543c4
Add example: change-the-path-property-of-an-external-link-in-an-xls-w…
agent-aspose-cells-examples May 21, 2026
2851d23
Add example: detect-hidden-external-links-within-the-workbook-using-t…
agent-aspose-cells-examples May 21, 2026
c6d6f5d
Add example: generate-a-plaintext-report-summarizing-hidden-external-…
agent-aspose-cells-examples May 21, 2026
ebd9c15
Add example: save-the-modified-workbook-as-an-xlsb-file-while-preserv…
agent-aspose-cells-examples May 21, 2026
ca1eeb8
Add example: validate-that-updating-a-powerqueryformulaitemvalue-corr…
agent-aspose-cells-examples May 21, 2026
8331cad
Add example: load-multiple-xls-files-from-a-directory-update-each-dbc…
agent-aspose-cells-examples May 21, 2026
96bdb04
Add example: export-a-list-of-all-external-connection-names-from-a-wo…
agent-aspose-cells-examples May 21, 2026
a548be6
Add example: compare-odata-connection-metadata-before-and-after-modif…
agent-aspose-cells-examples May 21, 2026
304de1d
Add example: use-workbookdatamashup-to-extract-odata-service-urls-and…
agent-aspose-cells-examples May 21, 2026
ee115be
Add example: programmatically-remove-a-hidden-external-link-from-the-…
agent-aspose-cells-examples May 21, 2026
1d16ea2
Add example: set-the-path-property-of-an-external-link-to-a-relative-…
agent-aspose-cells-examples May 21, 2026
b69683b
Add example: serialize-the-powerqueryformulacollection-to-xml-for-ext…
agent-aspose-cells-examples May 21, 2026
69b5375
Add example: load-an-xlsb-workbook-change-the-dbconnectionname-and-lo…
agent-aspose-cells-examples May 21, 2026
bb56241
Add example: detect-and-list-external-connections-of-type-webquery-ac…
agent-aspose-cells-examples May 21, 2026
8e2b5f6
Add example: update-the-source-file-location-of-a-power-query-data-so…
agent-aspose-cells-examples May 21, 2026
1c1dfdf
Add example: verify-that-hidden-external-links-remain-hidden-after-en…
agent-aspose-cells-examples May 21, 2026
53bde69
Add example: add-error-handling-to-capture-exceptions-when-an-externa…
agent-aspose-cells-examples May 21, 2026
ff1322a
Add example: generate-a-csv-file-containing-workbook-name-connection-…
agent-aspose-cells-examples May 21, 2026
8933593
Add example: replace-all-occurrences-of-a-deprecated-database-name-wi…
agent-aspose-cells-examples May 21, 2026
6e08084
Add example: change-the-absolute-path-of-an-external-link-data-source…
agent-aspose-cells-examples May 21, 2026
aafd9ae
Add example: validate-that-the-new-external-link-path-points-to-an-ex…
agent-aspose-cells-examples May 21, 2026
98a9694
Add example: update-all-external-links-in-the-workbook-to-use-relativ…
agent-aspose-cells-examples May 21, 2026
57b0711
Add example: log-the-original-and-updated-external-link-paths-for-aud…
agent-aspose-cells-examples May 21, 2026
5f49492
Add example: handle-errors-when-the-external-link-file-is-missing-or-…
agent-aspose-cells-examples May 21, 2026
2086cff
Add example: create-a-backup-of-the-workbook-before-modifying-externa…
agent-aspose-cells-examples May 21, 2026
1a43af1
Add example: add-a-custom-ribbon-tab-named-data-tools-using-ribbon-xm…
agent-aspose-cells-examples May 21, 2026
5ff5485
Add example: define-a-custom-ribbon-group-within-the-data-tools-tab-f…
agent-aspose-cells-examples May 21, 2026
04af732
Add example: disable-the-default-data-tab-in-the-ribbon-by-removing-i…
agent-aspose-cells-examples May 21, 2026
10cb3ef
Add example: hide-the-refresh-all-command-on-specific-worksheets-via-…
agent-aspose-cells-examples May 21, 2026
6aab93f
Add example: export-the-custom-ribbon-xml-to-a-separate-xml-file-for-…
agent-aspose-cells-examples May 21, 2026
fcc8d03
Add example: import-custom-ribbon-xml-from-an-external-xml-file-into-…
agent-aspose-cells-examples May 21, 2026
98f8033
Add example: validate-that-the-imported-ribbon-xml-conforms-to-the-of…
agent-aspose-cells-examples May 21, 2026
3a2d89e
Add example: add-a-tooltip-to-the-custom-ribbon-button-describing-its…
agent-aspose-cells-examples May 21, 2026
96b9cd1
Add example: assign-a-keyboard-shortcut-to-the-custom-ribbon-button-f…
agent-aspose-cells-examples May 21, 2026
fe4cb23
Add example: ensure-the-custom-ribbon-ui-loads-correctly-after-changi…
agent-aspose-cells-examples May 21, 2026
c476bca
Add example: test-the-custom-ribbon-button-to-confirm-it-successfully…
agent-aspose-cells-examples May 21, 2026
adc4e83
Add example: implement-error-handling-for-failures-during-external-li…
agent-aspose-cells-examples May 21, 2026
1bf17ab
Add example: use-a-file-picker-dialog-in-the-ribbon-button-to-select-…
agent-aspose-cells-examples May 21, 2026
10bfaad
Add example: save-the-workbook-with-updated-external-links-and-custom…
agent-aspose-cells-examples May 21, 2026
1942fe0
Add example: verify-that-the-workbook-opens-without-errors-after-appl…
agent-aspose-cells-examples May 21, 2026
91986ba
Add example: document-the-steps-to-customize-the-ribbon-xml-and-chang…
agent-aspose-cells-examples May 21, 2026
6ba3b40
Add example: create-a-unit-test-that-validates-external-link-path-cha…
agent-aspose-cells-examples May 21, 2026
24f6a11
Add example: package-the-custom-ribbon-xml-and-path-update-logic-into…
agent-aspose-cells-examples May 21, 2026
3d36c2d
Add example: provide-sample-code-demonstrating-how-to-programmaticall…
agent-aspose-cells-examples May 21, 2026
974d56e
Add example: ensure-the-solution-complies-with-security-best-practice…
agent-aspose-cells-examples May 21, 2026
1e48652
Add example: review-and-update-the-custom-ribbon-xml-to-maintain-comp…
agent-aspose-cells-examples May 21, 2026
4298d51
Update agents.md
agent-aspose-cells-examples May 31, 2026
7b059b1
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
160 changes: 160 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -8939,6 +8939,166 @@
"file": "iterate-through-dataconnections-to-identify-sql-type-connections-and-cast-each-to-dbconnection.cs",
"title": "Iterate through DataConnections to identify SQL type connections and cast each to DBConnection."
},
{
"category": "queries-and-connections",
"file": "add-a-custom-ribbon-tab-named-data-tools-using-ribbon-xml-definition.cs",
"title": "Add a custom ribbon tab named \"Data Tools\" using Ribbon XML definition."
},
{
"category": "queries-and-connections",
"file": "add-a-tooltip-to-the-custom-ribbon-button-describing-its-function-for-end-users.cs",
"title": "Add a tooltip to the custom ribbon button describing its function for end users."
},
{
"category": "queries-and-connections",
"file": "add-error-handling-to-capture-exceptions-when-an-external-connection-path-is-invalid.cs",
"title": "Add error handling to capture exceptions when an external connection path is invalid."
},
{
"category": "queries-and-connections",
"file": "assign-a-keyboard-shortcut-to-the-custom-ribbon-button-for-quick-access.cs",
"title": "Assign a keyboard shortcut to the custom ribbon button for quick access."
},
{
"category": "queries-and-connections",
"file": "change-description-property-of-a-dbconnection-to-reflect-its-new-purpose-after-migration.cs",
"title": "Change Description property of a DBConnection to reflect its new purpose after migration."
},
{
"category": "queries-and-connections",
"file": "change-the-absolute-path-of-an-external-link-data-source-file-programmatically-for-a-workbook.cs",
"title": "Change the absolute path of an external link data source file programmatically for a workbook."
},
{
"category": "queries-and-connections",
"file": "change-the-path-property-of-an-external-link-in-an-xls-workbook-to-a-network-shared-folder.cs",
"title": "Change the Path property of an external link in an XLS workbook to a network shared folder."
},
{
"category": "queries-and-connections",
"file": "compare-odata-connection-metadata-before-and-after-modification-to-ensure-version-consistency.cs",
"title": "Compare OData connection metadata before and after modification to ensure version consistency."
},
{
"category": "queries-and-connections",
"file": "create-a-backup-of-the-workbook-before-modifying-external-link-paths.cs",
"title": "Create a backup of the workbook before modifying external link paths."
},
{
"category": "queries-and-connections",
"file": "create-a-unit-test-that-validates-external-link-path-changes-and-custom-ribbon-integration.cs",
"title": "Create a unit test that validates external link path changes and custom ribbon integration."
},
{
"category": "queries-and-connections",
"file": "define-a-custom-ribbon-group-within-the-data-tools-tab-for-connection-management-commands.cs",
"title": "Define a custom ribbon group within the \"Data Tools\" tab for connection management commands."
},
{
"category": "queries-and-connections",
"file": "detect-and-list-external-connections-of-type-webquery-across-a-batch-of-workbooks.cs",
"title": "Detect and list external connections of type WebQuery across a batch of workbooks."
},
{
"category": "queries-and-connections",
"file": "detect-hidden-external-links-within-the-workbook-using-the-appropriate-api-and-list-their-source-paths.cs",
"title": "Detect hidden external links within the workbook using the appropriate API and list their source paths."
},
{
"category": "queries-and-connections",
"file": "disable-backgroundrefresh-on-a-sql-dbconnection-to-enforce-sequential-query-execution.cs",
"title": "Disable BackgroundRefresh on a SQL DBConnection to enforce sequential query execution."
},
{
"category": "queries-and-connections",
"file": "disable-preserveformatting-on-a-querytable-to-allow-default-formatting-during-subsequent-refreshes.cs",
"title": "Disable PreserveFormatting on a QueryTable to allow default formatting during subsequent refreshes."
},
{
"category": "queries-and-connections",
"file": "disable-the-default-data-tab-in-the-ribbon-by-removing-its-xml-definition.cs",
"title": "Disable the default \"Data\" tab in the ribbon by removing its XML definition."
},
{
"category": "queries-and-connections",
"file": "document-the-steps-to-customize-the-ribbon-xml-and-change-external-link-paths-in-a-developer-guide.cs",
"title": "Document the steps to customize the ribbon XML and change external link paths in a developer guide."
},
{
"category": "queries-and-connections",
"file": "enable-backgroundrefresh-on-a-webquery-connection-to-avoid-blocking-ui-during-retrieval.cs",
"title": "Enable BackgroundRefresh on a WebQuery connection to avoid blocking UI during retrieval."
},
{
"category": "queries-and-connections",
"file": "enable-preserveformatting-on-a-querytable-to-maintain-cell-styles-after-data-refresh.cs",
"title": "Enable PreserveFormatting on a QueryTable to maintain cell styles after data refresh."
},
{
"category": "queries-and-connections",
"file": "ensure-the-custom-ribbon-ui-loads-correctly-after-changing-external-link-paths.cs",
"title": "Ensure the custom ribbon UI loads correctly after changing external link paths."
},
{
"category": "queries-and-connections",
"file": "ensure-the-solution-complies-with-security-best-practices-when-handling-external-file-paths.cs",
"title": "Ensure the solution complies with security best practices when handling external file paths."
},
{
"category": "queries-and-connections",
"file": "export-a-list-of-all-external-connection-names-from-a-workbook-to-a-plain-text-file.cs",
"title": "Export a list of all external connection names from a workbook to a plain text file."
},
{
"category": "queries-and-connections",
"file": "export-the-custom-ribbon-xml-to-a-separate-xml-file-for-version-control.cs",
"title": "Export the custom ribbon XML to a separate .xml file for version control."
},
{
"category": "queries-and-connections",
"file": "extract-odata-connection-details-from-the-datamashup-object-and-log-the-service-endpoint-url.cs",
"title": "Extract OData connection details from the DataMashup object and log the service endpoint URL."
},
{
"category": "queries-and-connections",
"file": "generate-a-csv-file-containing-workbook-name-connection-type-and-connection-name-for-all-files-in-a-folder.cs",
"title": "Generate a CSV file containing workbook name, connection type, and connection name for all files in a folder."
},
{
"category": "queries-and-connections",
"file": "generate-a-plaintext-report-summarizing-hidden-external-link-paths-for-further-analysis.cs",
"title": "Generate a plain\u2011text report summarizing hidden external link paths for further analysis."
},
{
"category": "queries-and-connections",
"file": "handle-errors-when-the-external-link-file-is-missing-or-inaccessible-during-path-update.cs",
"title": "Handle errors when the external link file is missing or inaccessible during path update."
},
{
"category": "queries-and-connections",
"file": "hide-the-refresh-all-command-on-specific-worksheets-via-customized-ribbon-xml.cs",
"title": "Hide the \"Refresh All\" command on specific worksheets via customized Ribbon XML."
},
{
"category": "queries-and-connections",
"file": "implement-error-handling-for-failures-during-external-link-path-updates-invoked-from-the-ribbon.cs",
"title": "Implement error handling for failures during external link path updates invoked from the ribbon."
},
{
"category": "queries-and-connections",
"file": "import-custom-ribbon-xml-from-an-external-xml-file-into-an-existing-workbook-programmatically.cs",
"title": "Import custom ribbon XML from an external .xml file into an existing workbook programmatically."
},
{
"category": "queries-and-connections",
"file": "iterate-through-all-querytables-in-all-worksheets-and-set-preserveformatting-to-true.cs",
"title": "Iterate through all QueryTables in all worksheets and set PreserveFormatting to true."
},
{
"category": "queries-and-connections",
"file": "iterate-through-dataconnections-to-identify-sql-type-connections-and-cast-each-to-dbconnection.cs",
"title": "Iterate through DataConnections to identify SQL type connections and cast each to DBConnection."
},
{
"category": "queries-and-connections",
"file": "load-a-workbook-from-a-file-path-and-obtain-its-dataconnections-collection.cs",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using Aspose.Cells;

namespace AsposeCellsRibbonDemo
{
class Program
{
static void Main()
{
// Create a new workbook (in-memory)
Workbook workbook = new Workbook();

// Define the Ribbon XML that adds a custom tab named "Data Tools"
string ribbonXml =
"<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">" +
" <ribbon>" +
" <tabs>" +
" <tab id=\"dataToolsTab\" label=\"Data Tools\">" +
" <group id=\"dataToolsGroup\" label=\"Data Operations\">" +
" <button id=\"refreshButton\" label=\"Refresh\" size=\"large\" />" +
" </group>" +
" </tab>" +
" </tabs>" +
" </ribbon>" +
"</customUI>";

// Assign the Ribbon XML to the workbook
workbook.RibbonXml = ribbonXml;

// Save the workbook as a macro-enabled file (XLSM) to preserve the Ribbon UI
workbook.Save("DataToolsDemo.xlsm", SaveFormat.Xlsm);

// Optional: confirm that the Ribbon XML was set
Console.WriteLine("Custom Ribbon tab 'Data Tools' has been added and workbook saved.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.IO;
using Aspose.Cells;

namespace AsposeCellsDemo
{
public class AddRibbonTooltipDemo
{
public static void Main()
{
try
{
Run();
Console.WriteLine("Workbook saved successfully.");
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error: {ex.Message}");
}
}

public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();

// Define ribbon XML with a tooltip (ScreenTip) for the custom button
string ribbonXml =
"<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">" +
" <ribbon>" +
" <tabs>" +
" <tab id=\"customTab\" label=\"My Tab\">" +
" <group id=\"customGroup\" label=\"My Group\">" +
" <button id=\"customButton\" label=\"My Button\" size=\"large\" screentip=\"Executes the custom operation\" />" +
" </group>" +
" </tab>" +
" </tabs>" +
" </ribbon>" +
"</customUI>";

// Assign the custom ribbon XML to the workbook
workbook.RibbonXml = ribbonXml;

// Define output file path
string outputPath = "CustomRibbonWithTooltip.xlsm";

// Save the workbook (macro-enabled to retain ribbon UI)
workbook.Save(outputPath);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.IO;
using Aspose.Cells;
using Aspose.Cells.ExternalConnections;

namespace AsposeCellsExamples
{
public class ExternalConnectionInvalidPathHandling
{
public static void Main(string[] args)
{
Run();
}

public static void Run()
{
// Create a new workbook (lifecycle rule: create)
Workbook workbook = new Workbook();

// Attempt to work with external connections
try
{
// Access the external connections collection
ExternalConnectionCollection connections = workbook.DataConnections;

// If there is at least one connection, try to set an invalid ODC file path
if (connections.Count > 0)
{
ExternalConnection conn = connections[0];

// Intentionally set an invalid path to trigger an exception
conn.OdcFile = @"Z:\NonExistentFolder\InvalidConnection.odc";
}
else
{
Console.WriteLine("No external connections found in the workbook.");
}
}
catch (Exception ex)
{
// Capture and display any exception related to an invalid external connection path
Console.WriteLine($"Error while setting OdcFile: {ex.Message}");
}

// Attempt to add an external link with an invalid file path
try
{
// Get the external links collection
ExternalLinkCollection externalLinks = workbook.Worksheets.ExternalLinks;

// Define an invalid file name (non‑existent file)
string invalidFileName = @"C:\InvalidFolder\MissingWorkbook.xlsx";
string[] sheetNames = new string[] { "Sheet1" };

// Verify the file exists before attempting to add the link
if (File.Exists(invalidFileName))
{
int index = externalLinks.Add(invalidFileName, sheetNames);
Console.WriteLine($"External link added at index {index} (unexpected).");
}
else
{
Console.WriteLine($"File not found: {invalidFileName}. Skipping external link addition.");
}
}
catch (Exception ex)
{
// Capture and display any exception related to adding an invalid external link
Console.WriteLine($"Error while adding external link: {ex.Message}");
}

// Save the workbook (lifecycle rule: save)
try
{
workbook.Save("ExternalConnectionInvalidPathDemo.xlsx");
Console.WriteLine("Workbook saved successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error while saving workbook: {ex.Message}");
}
}
}
}
Loading