Skip to Content
0
Former Member
Jul 11, 2007 at 07:42 PM

How to open a excel document using BSP

44 Views

Hi All,

We have a Macro. I am opening a excel window with the data from a BSP. The macro should be automatically applied to Excel. I am writing JavaScript in a BSP and please find the code below. It opens data in a Excel window but the macro is not getting applied automatically. Any Suggestions?

function export_to_excel()

{

//cadrDetails = document.getElementById("cadrDetails");

var oExcel = new ActiveXObject("Excel.Application");

oBook = oExcel.Workbooks.Add("C:/\Program Files/\Microsoft Office/\Templates/\DPS_CAD.xlt");

//oSheet = oBook.Worksheets(1);

oSheet = oExcel.Workbooks(1).Sheets(1);

oSheet = oExcel.Workbooks(1).Sheets("Sheet1");

var rowSpanCells = new Array(cadrDetails.rows.length+1);

// Create table with actual rows and columns.

// HTML hides those rows/cols impacted by row/colspan

for (var y=0;y<cadrDetails.rows.length1;y+) {

rowSpanCells[y] = new Array(cadrDetails.rows(0).cells.length + 1);

}

excelRow = 1;

excelCol = 1;

for (var y=0;y<cadrDetails.rows.length;y+,excelRow+)

{

excelCol = 1;

for (var x=0;x<cadrDetails.rows(y).cells.length;x++)

{

setExcelText(oSheet, rowSpanCells, cadrDetails.rows(y).cells(x));

}

}

oSheet.Columns.AutoFit;

oSheet.Activate;

oExcel.Visible = true;

//oExcel.UserControl = true;

}

Thanks,

Naga