Steve Kershaw
2007-07-20 06:27:00 AM
On Jul 19, 8:11 am, "David Wier" <
davidw...@davidwier.nospam.com>
wrote:
>Could you explain, with a little more detail, what exactly you are trying to
>accomplish?
>
>--
>David Wier
>MVP/ASPInsider
aspnet101.comhttp://iWritePro.com
>
>"Steve Kershaw" <
steve_kers...@yahoo.com>wrote in message
>
>news:
1184853744.297769.246120@e9g2000prf.googlegroups.com...
>
>
>
>>Hi
>>I have an ASP.NET web page I'm working on and I need to see the
>>GridView Cell data in a javascript function. <%= %>doesn't work. Am I
>>missing something here?
>
>>Thanks
>>Steve- Hide quoted text -
>
>- 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