i'm using vb.net delete list of worksheets who's names appear in list box.
during research found 2 way delete items.
1) ctype(objworkbook.sheets("sheetname"), excel.worksheet).delete()
2) objworksheets.delete()
the loop use shown below:
for integer = 0 workbook_worksheets.items.count - 1 next
if use 1), delete doesn't , 2) don't know how assign names function specific worksheets deleted.
thank you
if you're using com interfaces excel modify workbook can (from here):
application.displayalerts=false each ws in sheets if ws.name = "master" ws.delete next application.displayalerts=true
com pretty slow interacting excel though, , have deal ui fiddly bits displayalerts disable/enable confirmation dialogs , like. should consider using library such eeplus create/edit xlsx , xlsm files without com. (this means app can run on machine without excel or different versions of excel etc.)
using eeplus this:
dim workbookfileinfo = new fileinfo("workbook.xlsx") using excelpackage = new excelpackage(workbookfileinfo) dim worksheet = excelpackage.workbook.worksheets.singleordefault(function(x) x.name = "worksheet1") excelpackage.workbook.worksheets.delete(worksheet) excelpackage.save() end using
Comments
Post a Comment