NodeDeveloper102
NodeDeveloper102

Reputation: 73

Using ActiveXOjbect and javascript to save a sheet with excel

Im using Javascript and ActiveXObject’s, look at this link here. I’m using ActiveXObject's to open an Excel file do some logic and save the file. What I need to accomplish is to open an Excel workbook that has multiple sheets, and save one of the sheets as a new Excel workbook(newfile.xlsx). This code below does exactly what I need it too except it saves as a CSV instead of a XLSX. I've tried using other numbers with the SaveAs() function, such as 1,4,8, I tried true. Some of those worked but none of them gave me the results I'm expecting. Is this type of task even possible to accomplish with ActiveXObject's and javascript? Any help is greatly appreciated!

/** IE 11 Only! **/
// ActiveXObject Example
var Excel = new ActiveXObject("Excel.Application");
Excel.DisplayAlerts = false;
var Book = Excel.Workbooks.Open(output_path+"file.xlsx");
Book.Worksheets("Sheet3”).SaveAs(output_path+"newfile.xlsx",6);
Excel_LI.DisplayAlerts = true;
Excel_LI.Quit();

Upvotes: 1

Views: 774

Answers (1)

xarxziux
xarxziux

Reputation: 371

Your answer is probably here somewhere, but there's a lot of different flavours of Excel listed. You may need some trial and error to figure out the one you need.

Upvotes: 1

Related Questions