A
Arvind R
Hello,
how to ask saveas dialog before writing the data to the excel file?
right now im able to save in c drive or any other specified location only.
any solution will be a great help!
System.Text.StringBuilder sbrHTML=new System.Text.StringBuilder("");
//StringBuilder sbrHTML = new StringBuilder();
SqlConnection cn = new
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand dc = new SqlCommand("Select * From wc_ingredient",cn);
SqlDataReader dr ;
int i=0;
cn.Open();
dr = dc.ExecuteReader();
//Making HTML
sbrHTML.Append("<TABLE Border=1 ID='Table1'>");
sbrHTML.Append("<TR><TD ColSpan=35><Font Size=5>Report</Font></TD><TR>");
sbrHTML.Append("<TR><TH>Id</TH><TH>Ingredient
Name</TH><TH>measure</TH><TH>Cost</TH><TH>Onhand Qty</TH><TH>Supplier
Code</TH><TH>Supplier Name</TH><TH>Supplier purchase unit</TH><TH>Supplier
Factor</TH><TH>Onhand Factor</TH><TH>Supplier Brand</TH><TH>Supplier
Case</TH><TH>Supplier Purchase unit</TH><TH>Supplier use
unit</TH><TH>Supplier cost unit</TH></TR>");
while(dr.Read())
{
i++;
sbrHTML.Append("<TR><TD>" + dr.GetValue(0).ToString() + "</TD><TD>"
+ dr.GetValue(1).ToString() + "</TD><TD>"
+ dr.GetValue(2).ToString() + "</TD><TD>"
+ dr.GetValue(3).ToString() + "</TD><TD>"
+ "</TR>" );
}
sbrHTML.Append("</TABLE>");
sbrHTML.Append("<BR><BR><B>Total Number of Ingredients are " + i.ToString()
+ "</B>");
string path="c:\\Ingredient_Report.xls";
StreamWriter swXLS =new StreamWriter("c:\\Report.xls");
swXLS.Write(sbrHTML.ToString());
swXLS.Close();
how to ask saveas dialog before writing the data to the excel file?
right now im able to save in c drive or any other specified location only.
any solution will be a great help!
System.Text.StringBuilder sbrHTML=new System.Text.StringBuilder("");
//StringBuilder sbrHTML = new StringBuilder();
SqlConnection cn = new
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand dc = new SqlCommand("Select * From wc_ingredient",cn);
SqlDataReader dr ;
int i=0;
cn.Open();
dr = dc.ExecuteReader();
//Making HTML
sbrHTML.Append("<TABLE Border=1 ID='Table1'>");
sbrHTML.Append("<TR><TD ColSpan=35><Font Size=5>Report</Font></TD><TR>");
sbrHTML.Append("<TR><TH>Id</TH><TH>Ingredient
Name</TH><TH>measure</TH><TH>Cost</TH><TH>Onhand Qty</TH><TH>Supplier
Code</TH><TH>Supplier Name</TH><TH>Supplier purchase unit</TH><TH>Supplier
Factor</TH><TH>Onhand Factor</TH><TH>Supplier Brand</TH><TH>Supplier
Case</TH><TH>Supplier Purchase unit</TH><TH>Supplier use
unit</TH><TH>Supplier cost unit</TH></TR>");
while(dr.Read())
{
i++;
sbrHTML.Append("<TR><TD>" + dr.GetValue(0).ToString() + "</TD><TD>"
+ dr.GetValue(1).ToString() + "</TD><TD>"
+ dr.GetValue(2).ToString() + "</TD><TD>"
+ dr.GetValue(3).ToString() + "</TD><TD>"
+ "</TR>" );
}
sbrHTML.Append("</TABLE>");
sbrHTML.Append("<BR><BR><B>Total Number of Ingredients are " + i.ToString()
+ "</B>");
string path="c:\\Ingredient_Report.xls";
StreamWriter swXLS =new StreamWriter("c:\\Report.xls");
swXLS.Write(sbrHTML.ToString());
swXLS.Close();