
June 5th, 2003, 09:13 PM
|
|
Registered User
|
|
Join Date: May 2003
Posts: 29
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I believe what dcarva said is true, however you can work around this<br>by writing the file server side. Here is what I mean:<br><br>One of my past programs, I allowed the client to fetch data and view it.<br>Then they would press a button that says "Excel" on it. When they press<br>the button, in my code behind, I would create a new html page as a stringbuilder, <br>then create a new file, and write the HTML to the new file.<br><br>Here is a simplified version of my code to help:<br>NOTE: REMOVE THE DECIMALS YOU SEE IN THE OPENING TAGS. <br>i.e. <.HTML>, <.HEAD>, <.FONT>, <.TABLE>, etc.<br><br>(The code will not post on this messageboard with the actual tags)<br><br><div class="msgQuoteWrap"><div class="msgCode"><br>Imports System.IO<br>Imports System.Text<br><br>Public Class WriteFile<br><br> Private Sub btnExcel_Click(ByVal sender.., ByVal e ..) Handles..<br> <br> 'Put Displayed Data into an Excel Spreadsheet<br><br> Dim oSB As New StringBuilder()<br><br> oSB.Append("<.HTML>")<br> oSB.Append("<.HEAD>")<br> oSB.Append("</head>")<br> oSB.Append("<.body>")<br> oSB.Append("<.form id=mainform method=post>")<br> oSB.Append("<.table class=Mtable id=MsgTable cellSpacing=0 cellPadding=0 width=95% align=center>")<br> oSB.Append("<.tr>")<br> oSB.Append("<.th bgColor=#336699 Align=center><.font color=#ffffff>Column 1</font></th>")<br> oSB.Append("<.th bgColor=#336699 Align=left><.font color=#ffffff>Column 2</font></th>")<br> oSB.Append("<.th bgColor=#336699 Align=right><.font color=#ffffff>Column 3</font></th>")<br> oSB.Append("<.th bgColor=#336699 Align=right><.font color=#ffffff>Column 4</font></th>")<br> oSB.Append("<.th bgColor=#336699 Align=right><.font color=#ffffff>Column 5</font></th>")<br> oSB.Append("</tr>")<br> oSB.Append("</table>")<br> oSB.Append("</form>")<br> oSB.Append("</body>")<br> oSB.Append("</html>")<br><br> Dim sXLSFile As String<br> Randomize() ' Initialize random-number generator.<br> sXLSFile = CInt(Int((1000 * Rnd()) + 0)) ' Generate a random value between 0 and 1000.<br><br> 'Create the New Excel File<br> Dim oFile As New StreamWriter("C:InetpubwwwrootExcelFile" & sXLSFile & ".xls")<br><br> oFile.Write(oSB.ToString)<br> oFile.Close()<br><br> 'Direct the User to View the Excel File<br> Response.Redirect("C:InetpubwwwrootExcelFile" & sXLSFile & ".xls")<br> End Sub<br><br>End Class<br></div></div><br><br>The only downside to this, is that the files will be stored on the server, but you can clean up the contents of the folder every so often. Since you will be writing text files, they will not be so big, so I wouldn't even worry about that. If you have any questions, just post it here.<br>Good Luck!
|