Could you explain, with a little more detail, what exactly you are trying to
accomplish?
--
David Wier
MVP/ASPInsiderhttp://aspnet101.comhttp://iWritePro.com
- Show quoted text -
Actually I figured it out. What I was trying to accomplish is sucking
the data from a GridView and putting it into an Excel spreadsheet. The
JavaScript code is quite simple:
// set up the Excel spreadsheet
var exApp = new ActiveXObject("Excel.Application");
exApp.visible = true;
var workbook = exApp.Workbooks.Add();
var rowcount = document.getElementById("<
%=GridView1.ClientID").rows.length;
var colcount = document.getElementById("<%=GridView1.ClientID
%>").rows[0].cells.length;
// describe the header row
workbook.ActiveSheet.Cells(1, 1) = "STR_NBR";
workbook.ActiveSheet.Cells(1, 2) = "FIT";
workbook.ActiveSheet.Cells(1, 3) = "FITGL";
workbook.ActiveSheet.Cells(1, 4) = "FUI";
workbook.ActiveSheet.Cells(1, 5) = "FUIGL";
workbook.ActiveSheet.Cells(1, 6) = "SIT";
workbook.ActiveSheet.Cells(1, 7) = "SITGL";
workbook.ActiveSheet.Cells(1, 8) = "SUI";
workbook.ActiveSheet.Cells(1, 9) = "SUIGL";
workbook.ActiveSheet.Cells(1, 10) = "ETF";
workbook.ActiveSheet.Cells(1, 11) = "ETFGL";
workbook.ActiveSheet.Cells(1, 12) = "SDI";
workbook.ActiveSheet.Cells(1, 13) = "SDIGL";
// fill in the rest of the cells.
for(var row = 1; row < rowcount; row++)
{
for(var col = 1; col < colcount + 1; col++)
{
workbook.ActiveSheet.Cells(row + 1, col) =
document.getElementById("<%=GridView1.ClientID
%>").rows[row].cells[col - 1].innerHTML;
}
}
Note that I don't know how to get the header row. All I recieve is the
HTML to descibe the header element.
Thanks
Steve