-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: prasanth
Message 1 in Discussion

Hi,   Please help to solve this issue.I have a datagrid where i am changing the 
column in run time and i am exporting the datagrid to Excel sheet.Now the issue 
is when i am exporting my datagrid to excel,the column names are not getting 
changed after expoting to excel.That is becoz it takes the cloumn name from 
datagrid not from the table generated after the postback.Now i want to get the 
names of the column names from the HTML table created .So below is the JS code 
that i have written,   function GetColumns()  {  var tab = 
document.getElementById("DataGrid1");  var firstrow = 
tab.childNodes[0].childNodes[0];   for(var i = 
0;i<firstrow.childNodes.length;i++)
          {
      
               document.getElementById("hdntest").value = 
document.getElementById("hdntest").value + firstrow.childNodes[i].innerText + 
";" ;
                
          } }   I am using  hidden server control to store the values  in my 
excel export function    
Public Sub ExcelExport(ByVal dg As DataGrid, ByVal title As String, ByVal file 
As String, ByVal colspan As String) 
Try 
Response.Clear() 
Response.ContentType = "application/vnd.ms-excel" 
Response.Charset = "" 
Me.EnableViewState = False 
Response.Write("<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">") 
Response.Write("" & Microsoft.VisualBasic.Chr(13) & "" & 
Microsoft.VisualBasic.Chr(10) & "") 
Response.Write("<style> .mystyle1 " + "" & Microsoft.VisualBasic.Chr(13) & "" & 
Microsoft.VisualBasic.Chr(10) & "" + 
"{mso-style-parent:style0;mso-number-format:""" + "\@" + """" + ";} " + "" & 
Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + 
"</style>") 
Response.Write("<table>") 
Response.Write("<tr color=gray>") 
Dim tw As StringWriter = New StringWriter 
Dim hw As HtmlTextWriter = New HtmlTextWriter(tw) 
'hdntest.Value = "" 
Dim strtest As String  
For Each oCol As DataGridItem In DataGrid1.Items 
strtest = CType(oCol.Cells(0).Controls(0), TextBox).Text  'Here it is throwing 
cast exception 
hdntest.Value += strtest + "," 
Next 
ClearControls(dg) 
dg.RenderControl(hw) 
Response.Write("<td colspan=" + colspan + " align='center'><FONT SIZE=2 
BOLD=true COLOR=Black>" + title + "</font></td>") 
Response.Write("</tr>") 
Response.AppendHeader("content-disposition", "attachment;filename=" + file + 
".xls") 
Response.Write(tw.ToString) 
Response.Write("</table>") 
Response.End() 
Catch generatedExceptionVariable0 As System.Threading.ThreadAbortException 
End Try 
End Sub 
  
Please let me know how can i handle this.I need an immediate solution. 
  
Thanks, 
Vishnu<FIRSTROW.CHILDNODES.LENGTH;I++)

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/Bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to