Reading an Excel File with Embedded Word Documents in C#
So right now my ASP.net app is working great, I am able to read the Excel file nothing fancy here:
string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Sample.xls;Extended Properties=\"Excel 8.0;HDR=Yes\"";
string SQLString = "SELECT * FROM [She开发者_如何学Pythonet1$]";
OleDbConnection DBConnection = new OleDbConnection(conString);
OleDbCommand DBCommand = new OleDbCommand(sQuery, DBConnection);
IDataReader iReader = DBCommand.ExecuteReader();
After this I can display the spreadsheet on a DataGrid object and most of the cells look fine.
However, this spreadsheet contains embedded word documents in some of the cells. For example, if I highlight the cell I see "=EMBED("Word.Document.8","")" and there is a word document there in the cell.
So my question is does anyone know how I can access these embedded word documents? Right now the cells just show up as empty on my DataGrid.
I don't think you will be able to do this with OLEDB. You will have to rely on COM Interop to get the data out. Check out http://msdn.microsoft.com/en-us/library/ff597926.aspx
精彩评论