[RESOLVED] Export To Excel
Hi, I'm exporting data to Excel. I've to put some headings, some data from datatable and again some footer text. For that I'm using following Code. It works fine locally but when I publish it it gives error while saving excel file as I'm hosting it on shared server. Can someone Help?
Code:
'--SOME HEADERS
Dim HtmlStream As String
HtmlStream = "<html><body><br/><div style='padding:15px;font-family:Tahoma;font-size:11px;'>"
HtmlStream += "<table cellpadding='0' cellspacing='0' border='1' style='line-height:20px; border:solid 1px;font-size:11px;' width='100%'><tr><td colspan='8' style='height:20px;'></td></tr> <tr><Td colspan='8'>"
HtmlStream += "<div style='padding-left:20px;'><b>MULTIPLE TRANSACTIONS REQUEST FORM</b><br /><b>Date -" + DateTime.Now + "</b><br /><b>Name of Applicant - ABC CO. LTD.NEFT</b><br />"
'--CODE FROM DATATABLE
For i = 0 To mSeta.Rows.Count - 1
If Len(Trim(mSeta.Rows(i)(3))) > 0 Then
If mSeta.Rows(i)(8) > 500 Then
HtmlStream += "<tr style='line-height:30px;'><td style='width:10px;' align='right'>" + Convert.ToString(sNo) + "</td>"
HtmlStream += "<td align='right'>" + Convert.ToString(mSeta.Rows(i)(8)) + "</td><td align='left'>804-0-507995-6</td>"
HtmlStream += "<td align='left'>" + mSeta.Rows(i)(6) + "</td>"
HtmlStream += "<td align='left'>" + mSeta.Rows(i)(3) + "," + mSeta.Rows(i)(4) + "</td>"
HtmlStream += "<td align='left'>" + mSeta.Rows(i)(5) + "</td>"
HtmlStream += "<td align='left'>" + mSeta.Rows(i)(1) + "</td><td align='left'>INCENTIVE</td></tr>"
MyTotal = MyTotal + mSeta.Rows(i)(8)
sNo = sNo + 1
End If
End If
Next
'--SOME FOOTER
HtmlStream += "<tr style='line-height:20px;'><td colspan='8' style='padding-left:50px;'>Total Amount to be transferred. <b>" + Convert.ToString(MyTotal) + "</b><br />"
HtmlStream += "Total Number Of Items <b>" + Convert.ToString(sNo - 1) + "</b><br /><br />"
'--NOW SAVING
Dim file As New System.IO.StreamWriter("Commission.xls")
file.WriteLine(HtmlStream) ';// now writing the stream to the file
file.Close() ';// closing the streamwriter
'// Provide the actual path if not using this default path
Process.Start("Commission.xls") ';// Opening the excel sheet
It gives error while saving