-
April 23rd, 2013, 10:49 AM
#1
Converting HTML export to Excel..
Hello all... I currently am working on a program that exports to an HTML document. I am trying to get it exporting to excel and am not sure where to start (never exported to excel before). I have Excel referenced but can't get much further. Here's a bit of the first HTML section I'm working on:
Code:
private void HtmlWriteIntro(StreamWriter sw, string credit)
{
string customer = "cust";
string reference = "ref";
DateTime doc_date = DateTime.Now;
try
{
string q = @"
SELECT CreditNumber, Customer, DocumentNumber, AdditionDate
FROM viewCmCreditReportSrcAll
WHERE (CreditNumber = @credit)";
List<string> vp = new List<string>();
vp.Add("credit");
List<string> vv = new List<string>();
vv.Add(credit);
DataTable dt = ExecuteQuery("MobileScan", q, vp, vv);
customer = dt.Rows[0].ItemArray[1].ToString();
reference = dt.Rows[0].ItemArray[2].ToString();
doc_date = DateTime.Parse(dt.Rows[0].ItemArray[3].ToString());
}
catch { }
sw.WriteLine("<table border=\"0\" style=\"font-family:Verdana; font-size:x-small;\" width=\"100%\">");
sw.WriteLine("<tr>");
sw.WriteLine("<td align=\"left\"><span style=\"font-size:large\"><b>Credit Comparison Report</b></span></td>");
sw.WriteLine("<td align=\"right\"><span style=\"font-size:x-small\"><b>Print Date:</b> " + DateTime.Now.ToLongDateString() + "</span></td>");
sw.WriteLine("</tr>");
sw.WriteLine("<tr>");
sw.WriteLine("<td align=\"left\"><span style=\"font-size:medium\"><b>Credit Number " + credit + "</b></span></td>");
sw.WriteLine("<td align=\"right\"> </td>");
sw.WriteLine("</tr>");
sw.WriteLine("<tr>");
sw.WriteLine("<td align=\"left\"><b>Document Date:</b> " + doc_date.ToShortDateString() + "</td>");
sw.WriteLine("<td align=\"right\"> </td>");
sw.WriteLine("</tr>");
sw.WriteLine("<tr>");
sw.WriteLine("<td align=\"left\"><b>Customer:</b> " + customer + "</td>");
sw.WriteLine("<td align=\"right\"> </td>");
sw.WriteLine("</tr>");
sw.WriteLine("<tr>");
sw.WriteLine("<td align=\"left\"><b>Reference #:</b> " + reference + "</td>");
sw.WriteLine("<td align=\"right\"> </td>");
sw.WriteLine("</tr>");
sw.WriteLine("<tr>");
sw.WriteLine("<td align=\"right\" colspan=\"2\"><hr /></td>");
sw.WriteLine("</tr>");
sw.WriteLine("</table>");
}
Any tips/guidance would be greatly appreciated.
-
April 23rd, 2013, 02:30 PM
#2
Re: Converting HTML export to Excel..
Why not just select the query in Excel? It can open SQL tables.
-
April 24th, 2013, 09:05 AM
#3
Re: Converting HTML export to Excel..
Originally Posted by dglienna
Why not just select the query in Excel? It can open SQL tables.
Not possible.
How about creating a button that exports the html doc to excel? Might be a lazy way about it but I need to get this done
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|