Hello all, this is my first question here. I am using Visual Studio 2010 and I want to design an Excel Addin for a sales catalog. It has two forms and I got one of them working but the other one not. What I want to achieve is that I open up a Windows form through the Addin and through the form I get data from my Access database. I import the data into a datagrid and then I export the data to Excel.
I got this part working but I have problems with my next form. In that form I want to open up a Word template ( when I press a button) and then the data from the open Excel file is transferred into my Word document.
Does anybody know what would be the best way to do this?
I use OleDBConnection to get the data from the database to the datagrid. I am designing this for Office 2007 and I am programming in C#.
Thanks in advance.
Here is part of my code. I use this part to get the data from the Excel file into a DataGrid but I want to be able to bring that data into a WordDocument.
Does anybody know what is the best way to do that.
DataSet da = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter();
string workbookPath = "C:myfile.xlsx";
Excel.Workbook wb = Globals.ThisAddIn.Application.Workbooks.Add(workbookPath);
string ConnectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + workbookPath
+ @";Extended Properties=""Excel 12.0 Macro;HDR=Yes;ImpoertMixedTypes=Text;TypeGuessRows=0""";
OleDbConnection conn = new OleDbConnection(ConnectionString);
string strCmd = " select * from [Sheet1$A1:D4]";
OleDbCommand cmd = new OleDbCommand(strCmd, conn);
adapter.SelectCommand = cmd;
dataGridView1.DataSource = da.Tables;