Accedi a QueryTable di Excel usando C#

Follow this article to access and update a Excel QueryTable using C#. It contains details for setting up the IDE, a list of steps, and a code example for accessing and modifying an Excel query table using C#. You will learn to control and access the query table collection, retrieve it, and update its properties if necessary.

Steps to refresh the external data connection of Excel with C#.

  1. Set the IDE to use Aspose.Cells for .NET to work with the query table.
  2. Upload the Excel file to the Workbook object containing the QueryTable.
  3. Access the first sheet, get the collection of QueryTable objects, and take the first QueryTable.
  4. Print the basic information of the QueryTable.
  5. Verifica l’esistenza della connessione esterna e visualizza le sue proprietà
  6. Update the connection settings in the QueryTable object.
  7. Write the updated properties and save the workbook.

These steps summarize how to work with an external data connection using C# in an Excel file. Load the Excel file into the Workbook object, access the first sheet, retrieve the collection of query tables, print the query table data, and update its properties. Access the external connection in the query table, update its properties, and save it to disk.

Codice per aggiornare la connessione QueryTable usando C#

This code demonstrates how to perform various operations on an Excel QueryTable. Make sure to set AdjustColumnWidth and PreserveFormatting together, as they are commonly paired in the query table output. Also, check whether the QueryTable still exists after making changes, as improper modifications may not save the QueryTable in the output Excel file.

This article taught us the process for working with the query table in an Excel file. To create subtotals in an Excel file, refer to the article Creating subtotals in Excel using C#.

 Italiano