How to update data in Excel file using OLEDB
In the previous examples, we relied on the Microsoft Excel 12.0 Object Library to perform read and write operations on Excel files. However, in C#, an alternative approach allows us to manipulate cell content in an Excel file without utilizing the Excel Object model. This can be achieved by leveraging OLEDB (Object Linking and Embedding Database) technology.
To execute these operations, we employ components such as OleDbConnection, OleDbDataAdapter, and DataSet within the System.Data namespace. These components provide the necessary functionalities to carry out tasks such as inserting, editing, deleting, and selecting cell content in an Excel file. Importing the System.Data namespace into the project is crucial to utilize these components effectively.
When updating or modifying the content within a cell, we can employ the UPDATE command, similar to SQL operations, to seamlessly perform the desired modifications on the cell content.
Sample UPDATE sql
The following picture shows before and after update of the Sheet.Full Source C#
Adopting this approach, developers can efficiently interact with Excel files, manipulating cell content without the direct dependency on the Excel Object model, thus offering enhanced flexibility and efficiency in Excel file manipulation.