I'm trying to export the contents of a datagrid to excel which I have been able to do as long as its to a generic excel workbook. I can't figure out how to direct to open a specific workbook, create a new tab with a name that I create in code, & save the datagrid to that. tab(worksheet).
For example I want it to open C:\mydocuments\myworkbook.xls, create a new worksheet named "0914 to 0920", and export the datgrid to that.
I've been able to designate a file name but no luck with path or worksheet names
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=" & myfilename)
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.xls"
GridView2.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()