Write to protected Excel File in C# -


there file in want write using c#, can't, i´ve checked permissons , read-only properties of file not turned on. i'm trying this:

excel.application xlapp; excel.workbook xlworkbook; excel.worksheet xlworksheet1; xlapp = new excel.application(); xlworkbook = xlapp.workbooks.open(directory.getcurrentdirectory() + "\\template.xls"); xlworksheet1 = (excel.worksheet)xlworkbook.worksheets.get_item(1); xlworksheet1.cells[1, 1] = "h1"; xlworkbook.saveas(savefiledialog1.filename, excel.xlfileformat.xlworkbooknormal, misvalue, misvalue, misvalue, misvalue, excel.xlsaveasaccessmode.xlexclusive, misvalue, misvalue, misvalue, misvalue, misvalue); xlapp.quit(); releaseobject(xlworksheet1); releaseobject(xlworkbook); releaseobject(xlapp); 

it works when use other file when use "template.xls" nothing, there isn't errors, appears work good, when open created file there nothing new on it. question is, there permisson or rule i'm forgeting?

i found easier solution, copied content of file new file , worked, dont know why or how worked. posting.


Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -