I want to accomplish the following task.
-
I have an web application through which I will be calling an VSTO apps, I have to insert some values in one of the sheets of the excel workbook
-
I will be inserting the values in the excel sheet and will have to upload to DB using upload button.
What have I done so far.
-
I created a web apps solution. “C:\Examples\WebVSTO\WebVSTO\WebVSTO”
-
I created a VSTO solution. “C:\Examples\VSTO2007\VSTO2007\VSTO2007.xlsx”
-
I insert the values in the excel sheet as below:
System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"C:\Examples\VSTO2007\VSTO2007\VSTO2007.xlsx" + ";Extended Properties=Excel 8.0;"); objConn.Open(); System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand(); objCmd.Connection = objConn; objCmd.CommandText = "Insert into [Sheet1$]" + " values ('Test')"; objCmd.ExecuteNonQuery(); objConn.Close(); -
I ran the web application, and observed that the values were inserted in the excel.
-
I upload the values from the excel, by running the VSTO solution and the values got uploaded to the DB.
Issues
- The excel(only the VSTO excel and not the whole solution) will be placed in a different folder. When I hit the download button in the web apps, the excel will be downloaded in the clients place.
I face the above issue. How do I respond.
Kindly let me know.
Thanks in advance.
If I understand correctly, The question is quite a generic question: “How do I make a file not on the web application folder available for download?”
The simple way to do it is by writing the binary code into the Response Stream and setting some headers.
I didn’t test it but it should work.