c# - How to name excel sheets using interop -
i made sheets in excel file. made lot @ same time code:
newsheet2 = (microsoft.office.interop.excel._worksheet)newworkbook_first.sheets.add(type.missing,type.missing,5,type.missing);
...but don't know how name them individually. thought had way:
newsheet2[2].name = "hello"
but gave error. how can this?
private static microsoft.office.interop.excel.applicationclass appexcel; private static workbook newworkbook_first = null; private static _worksheet newsheet2 = null; public void excel_create(string path) { try { appexcel = new microsoft.office.interop.excel.applicationclass(); appexcel.visible = true; newworkbook_first = appexcel.workbooks.add(1); newsheet2 = (microsoft.office.interop.excel._worksheet)newworkbook_first.sheets.add(type.missing,type.missing,5,type.missing); //how name sheets now? } catch (exception e) { console.write("error"); } { } }
you close, use 'name', not 'name':
application.activesheet.name="myname";
Comments
Post a Comment