user1545707
user1545707

Reputation: 21

Adding worksheet to the excel file selected by user

I am using ActiveX object to add worksheet to the user selected excel file. With the below code its working. ( This is a IE fix, so using ActiveX )

var excel = new ActiveXObject("Excel.Application"); 
  var excel_file = excel.Workbooks.Open(path); 
  var ws = excel_file.Worksheets;
  resultSheet = ws.Add();

But created worksheet is adding at first, I want to add it after the existing sheets in the excel. Is it possible ? What parameters should I pass it to Add method ?

Upvotes: 2

Views: 2689

Answers (1)

RowanC
RowanC

Reputation: 1649

I think brettdj had the gist of it, try:

var excel = new ActiveXObject("Excel.Application"); 
var excel_file = excel.Workbooks.Open(path); 
var ws = excel_file.Worksheets;
resultSheet = ws.Add(null,ws(ws.Count));

Upvotes: 1

Related Questions